Browse Source

added kestra boilerplates

Christian Lempa 1 năm trước cách đây
mục cha
commit
743e25a974
3 tập tin đã thay đổi với 65 bổ sung0 xóa
  1. 19 0
      kestra/python/command.yaml
  2. 28 0
      kestra/python/script.yaml
  3. 18 0
      kestra/webhook.yaml

+ 19 - 0
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

+ 28 - 0
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}}"

+ 18 - 0
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!