From 743e25a974867535cc87a7bb4ae273b2c320a6bf Mon Sep 17 00:00:00 2001 From: Christian Lempa Date: Fri, 19 Apr 2024 14:41:05 +0200 Subject: [PATCH] added kestra boilerplates --- kestra/python/command.yaml | 19 +++++++++++++++++++ kestra/python/script.yaml | 28 ++++++++++++++++++++++++++++ kestra/webhook.yaml | 18 ++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 kestra/python/command.yaml create mode 100644 kestra/python/script.yaml create mode 100644 kestra/webhook.yaml diff --git a/kestra/python/command.yaml b/kestra/python/command.yaml new file mode 100644 index 0000000..0a42edc --- /dev/null +++ b/kestra/python/command.yaml @@ -0,0 +1,19 @@ +# Kestra Python Command Template +# --- +# +# This template is a simple Python script. +# +# usage: +# make sure the Kestra instance can access the /app/scripts/your-python-script.py file +# if you're running Kestra in Docker, use a volume to mount the file/directory. + +id: python-command +namespace: # your-namespace + +tasks: + + - id: python_command + type: io.kestra.plugin.scripts.python.Commands + commands: + - python /app/scripts/your-python-script.py + runner: PROCESS # or DOCKER (might be deprecated in the future) use TaskRunner instead diff --git a/kestra/python/script.yaml b/kestra/python/script.yaml new file mode 100644 index 0000000..fd90e74 --- /dev/null +++ b/kestra/python/script.yaml @@ -0,0 +1,28 @@ +# Kestra Python Command Template +# --- +# +# This template is a simple Python script that can be used to make a request to a website and log the status code. +# + +id: python-script +namespace: # your-namespace + +tasks: + + - id: python_script + type: io.kestra.plugin.scripts.python.Script + runner: DOCKER # (might be deprecated in the future) use TaskRunner instead + script: | + from kestra import Kestra + import requests + + response = requests.get('{{inputs.website}}') + print(response.status_code) + + Kestra.outputs({'status': response.status_code, 'text': response.text}) + beforeCommands: + - pip install requests kestra + + - id: log + type: io.kestra.core.tasks.log.Log + message: "StatusCode: {{outputs.pythonscript.vars.status}}" diff --git a/kestra/webhook.yaml b/kestra/webhook.yaml new file mode 100644 index 0000000..cf97848 --- /dev/null +++ b/kestra/webhook.yaml @@ -0,0 +1,18 @@ +# Kestra Webhook Template +# --- +# +# This template is a simple webhook trigger that can be used to trigger a task execution. +# +# usage: +# curl http://your-kestra-instance/api/v1/executions/webhook/your-namespace/your-task-id/your-secret-key + +id: webhook +namespace: # your-namespace + +tasks: + # your-tasks + +triggers: + - id: webhook + type: io.kestra.core.models.triggers.types.Webhook + key: # your-secret-key, keep this secret!