Skip to content

Commit

Permalink
chore: add example for pyhton taskdef
Browse files Browse the repository at this point in the history
Signed-off-by: realanna <anna.reale@dynatrace.com>

chore: add example for pyhton taskdef

Signed-off-by: realanna <anna.reale@dynatrace.com>

chore: add example for pyhton taskdef

Signed-off-by: realanna <anna.reale@dynatrace.com>

fix: remove space

Signed-off-by: realanna <anna.reale@dynatrace.com>

fix: remove space

Signed-off-by: realanna <anna.reale@dynatrace.com>

Apply suggestions from code review

Co-authored-by: Moritz Wiesinger <moritz.wiesinger@dynatrace.com>
Signed-off-by: RealAnna <89971034+RealAnna@users.noreply.github.com>
  • Loading branch information
RealAnna and mowies committed Jun 13, 2023
1 parent 21e4ba3 commit 0789b3a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 30 deletions.
13 changes: 5 additions & 8 deletions docs/config/_default/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ title: Keptn
module:
hugoVersion:
extended: true
mounts:
source: content/en
target: content
imports:
- path: github.com/keptn/docs-tooling
ignoreConfig: false
Expand All @@ -31,12 +28,12 @@ module:
- source: "README.md"
target: "./content/community/_index.md"
- path: github.com/keptn/lifecycle-toolkit/operator
ignoreConfig: true
ignoreImports: true
noVendor: true
mounts:
- source: ./config/samples
target: ./content/yaml
- source: "./config/samples/python_execution"
target: ./content/yaml_py
includeFiles: "**/*.yaml"
- source: "./config/samples/function_execution"
target: ./content/yaml_deno
includeFiles: "**/*.yaml"

proxy: direct
Expand Down
33 changes: 18 additions & 15 deletions docs/content/en/docs/implementing/tasks/python.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Working with python runtime for Keptn tasks
description: Learn how to work with Keptn tasks using python
title: Working with Python runtime for Keptn tasks
description: Learn how to work with Keptn tasks using Python
weight: 90
hidechildren: false # this flag hides all sub-pages in the sidebar-multicard.html

Expand All @@ -19,34 +19,37 @@ The Python code can be specified as:

## Inline

You can embed python code directly in the task definition.
You can embed Python code directly in the task definition.
Consider the following example, where we print data stored in the parameters map:
{{< readfile file="/yaml/python_execution/taskdefinition_pyfunction_inline.yaml" code="true" lang="yaml" >}}
{{< readfile file="/yaml_py/taskdefinition_pyfunction_inline.yaml" code="true" lang="yaml" >}}

## HTTP reference

## Http reference
You can refer to a code stored online, for instance we have a few examples available [here](https://github.com/keptn/lifecycle-toolkit/tree/main/python-runtime/samples).
Consider the following:
{{< readfile file="/yaml/python_ execution/taskdefinition_pyfunction_configmap.yaml" code="true" lang="yaml" >}}
{{< readfile file="/yaml_py/taskdefinition_pyfunction_configmap.yaml" code="true" lang="yaml" >}}

## Refer to another TaskDefinition

You can refer to an existing taskDefinition.
Consider the following example, this will call the inline example but will override the data printed with what is specified in the task:
{{< readfile file="/yaml/python_ execution/taskdefinition_pyfunction_recursive.yaml" code="true" lang="yaml" >}}
You can refer to an existing `KeptnTaskDefinition`.
Consider the following example, this will call the inline example but will override the data printed with
what is specified in the task:
{{< readfile file="/yaml_py/taskdefinition_pyfunction_recursive.yaml" code="true" lang="yaml" >}}

## Config Map

Consider the following example:
{{< readfile file="/yaml/python_ execution/taskdefinition_pyfunction_configmap.yaml" code="true" lang="yaml" >}}
{{< readfile file="/yaml_py/taskdefinition_pyfunction_configmap.yaml" code="true" lang="yaml" >}}

## Allowed libraries for the Python runtime

The following example shows how to use few of the allowed packages, namely: requests, json, git, yaml
{{< readfile file="/yaml/python_ execution/taskdefinition_pyfunction_inline_printargs_py.yaml" code="true" lang="yaml" >}}
{{< readfile file="/yaml_py/taskdefinition_pyfunction_inline_printargs_py.yaml" code="true" lang="yaml" >}}

## Passing secrets, env vars and modifying the python command
## Passing secrets, environment variables and modifying the Python command

In the following examples you can see how to pass data inside the parameter map, how to load a secret in your code and finally how to modify the python command.
In this case the container will run with the option -h which will print the help of the python3 command.
In the following examples you can see how to pass data inside the parameter map, how to load a secret in your code,
and finally how to modify the Python command.
In this case the container will run with the option -h which will print the help of the Python3 command.

{{< readfile file="/yaml/python_ execution/taskdefinition_pyfunction_use_envvars.yaml" code="true" lang="yaml" >}}
{{< readfile file="/yaml_py/taskdefinition_pyfunction_use_envvars.yaml" code="true" lang="yaml" >}}
6 changes: 4 additions & 2 deletions docs/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/keptn/keptn-lifecycle-toolkit/docs

go 1.20

replace github.com/keptn/lifecycle-toolkit/operator => github.com/keptn/lifecycle-toolkit/operator v0.0.0-20230613082428-2d588dbfd240

require (
github.com/argoproj/argo-rollouts v1.5.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
Expand Down Expand Up @@ -31,12 +33,12 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/keptn/community v0.0.0-20230429154843-72d65a6e2b39 // indirect
github.com/keptn/community v0.0.0-20230612175546-3da2fa53a0c5 // indirect
github.com/keptn/docs-tooling v0.1.1 // indirect
github.com/keptn/lifecycle-toolkit v0.7.1 // indirect
github.com/keptn/lifecycle-toolkit/klt-cert-manager v0.0.0-20230601122212-9eafb78b51d6 // indirect
github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230601125711-bb916f3e3875 // indirect
github.com/keptn/lifecycle-toolkit/operator v0.0.0-20230612132640-751552cb7d5c // indirect
github.com/keptn/lifecycle-toolkit/operator v0.0.0-20230613082428-2d588dbfd240 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand Down
13 changes: 8 additions & 5 deletions docs/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/FortAwesome/Font-Awesome v0.0.0-20220831210243-d3a7818c253f/go.mod h1:IUgezN/MFpCDIlFezw3L8j83oeiIuYoj28Miwr/KUYo=
github.com/FortAwesome/Font-Awesome v0.0.0-20230327165841-0698449d50f2/go.mod h1:IUgezN/MFpCDIlFezw3L8j83oeiIuYoj28Miwr/KUYo=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/argoproj/argo-rollouts v1.5.1 h1:P1C6oIWn6fwtPvB3u04NQlUGIv8cq/aJvUkbwciuWYo=
Expand Down Expand Up @@ -145,9 +146,10 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/docsy v0.6.0 h1:43bVF18t2JihAamelQjjGzx1vO2ljCilVrBgetCA8oI=
github.com/google/docsy/dependencies v0.6.0 h1:BFXDCINbp8ZuUGl/mrHjMfhCg+b1YX+hVLAA5fGW7Pc=
github.com/google/docsy/dependencies v0.6.0/go.mod h1:EDGc2znMbGUw0RW5kWwy2oGgLt0iVXBmoq4UOqstuNE=
github.com/google/docsy/dependencies v0.7.0 h1:/xUlWCZOSMDubHfrhIz1YtaRn2Oc/swfJ7OUfglXE8U=
github.com/google/docsy/dependencies v0.7.0/go.mod h1:gihhs5gmgeO+wuoay4FwOzob+jYJVyQbNaQOh788lD4=
github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0=
github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
Expand Down Expand Up @@ -204,8 +206,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/keptn/community v0.0.0-20230429154843-72d65a6e2b39 h1:cexkJyNwTSwU+XgNKbu3ttr71rK/W9AwuyqUdefzPfc=
github.com/keptn/community v0.0.0-20230429154843-72d65a6e2b39/go.mod h1:0G5nUhSv7ch9BgIFXiY7+U+cV5SbVmneysNGQwQkH8s=
github.com/keptn/community v0.0.0-20230612175546-3da2fa53a0c5 h1:FYO6bZboEtJZj36Rrsb3hwdHK0wY6W5/JneBxbb6CYQ=
github.com/keptn/community v0.0.0-20230612175546-3da2fa53a0c5/go.mod h1:0G5nUhSv7ch9BgIFXiY7+U+cV5SbVmneysNGQwQkH8s=
github.com/keptn/docs-tooling v0.1.1 h1:IuI0Fgs0JrtffLN05iaRZVkRMbPu6h9bxR4C8q1ApGU=
github.com/keptn/docs-tooling v0.1.1/go.mod h1:x0iT5YsJosz6wzjQke/YaLgiXF6PV+N8QzxSAc2MY/4=
github.com/keptn/lifecycle-toolkit v0.7.1 h1:vBFT9BkQOy23f/+QQhA+n18vtuRgFcZlk3E8mihabww=
Expand All @@ -214,8 +216,8 @@ github.com/keptn/lifecycle-toolkit/klt-cert-manager v0.0.0-20230601122212-9eafb7
github.com/keptn/lifecycle-toolkit/klt-cert-manager v0.0.0-20230601122212-9eafb78b51d6/go.mod h1:KVv7ImFCBfxN6ocWUeciS31FCHDg7IZD6nfCnuT3mxQ=
github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230601125711-bb916f3e3875 h1:YYzXE9wA9UJikjhq9oBaUdDjZ6JmUDR+7+Sa1a/YT7E=
github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230601125711-bb916f3e3875/go.mod h1:gqIbzhBpk4F6OmDDF25G4L5A9MXJNfd7UP6ATLFFLi0=
github.com/keptn/lifecycle-toolkit/operator v0.0.0-20230612132640-751552cb7d5c h1:PGq42pGUDV8IU/QsmGInWI/LTGIBQG37VIeqlAwftZI=
github.com/keptn/lifecycle-toolkit/operator v0.0.0-20230612132640-751552cb7d5c/go.mod h1:kvAsPNqbcQrPT8/uqmY/Mt3PWhz3WMZi8eJODai1e3U=
github.com/keptn/lifecycle-toolkit/operator v0.0.0-20230613082428-2d588dbfd240 h1:qbOhwFM08KLQxxlvmkHKiQQoWMLni86GVabWwKPXPYA=
github.com/keptn/lifecycle-toolkit/operator v0.0.0-20230613082428-2d588dbfd240/go.mod h1:kvAsPNqbcQrPT8/uqmY/Mt3PWhz3WMZi8eJODai1e3U=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
Expand Down Expand Up @@ -264,6 +266,7 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/twbs/bootstrap v4.6.2+incompatible/go.mod h1:fZTSrkpSf0/HkL0IIJzvVspTt1r9zuf7XlZau8kpcY0=
github.com/twbs/bootstrap v5.2.3+incompatible/go.mod h1:fZTSrkpSf0/HkL0IIJzvVspTt1r9zuf7XlZau8kpcY0=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
Expand Down

0 comments on commit 0789b3a

Please sign in to comment.