diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 6b0a5bc334..ed80b39b2c 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -366,6 +366,7 @@ kustomize kustomizeconfig kwi kwv +kwds kyverno lastword Lato diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml index 2df44b47f5..37834b7eaa 100644 --- a/.markdownlint-cli2.yaml +++ b/.markdownlint-cli2.yaml @@ -9,6 +9,7 @@ config: allowed_elements: - details - summary + - a github-admonition: true max-one-sentence-per-line: true diff --git a/docs/docs/assets/crd/examples/configmap-for-deno-script.yaml b/docs/docs/assets/crd/examples/configmap-for-deno-script.yaml new file mode 100644 index 0000000000..07516b4a9a --- /dev/null +++ b/docs/docs/assets/crd/examples/configmap-for-deno-script.yaml @@ -0,0 +1,30 @@ +apiVersion: lifecycle.keptn.sh/v1beta1 +kind: KeptnTaskDefinition +metadata: + name: scheduled-deployment +spec: + function: + configMapRef: + name: scheduled-deployment-cm-1 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: scheduled-deployment-1 +data: + code: | + let text = Deno.env.get("DATA"); + let data; + if (text != "") { + data = JSON.parse(text); + } + let targetDate = new Date(data.targetDate) + let dateTime = new Date(); + if(targetDate < dateTime) { + console.log("Date has passed - ok"); + Deno.exit(0); + } else { + console.log("It's too early - failing"); + Deno.exit(1); + } + console.log(targetDate); diff --git a/docs/docs/assets/crd/examples/configmapref-for-deno-script.yaml b/docs/docs/assets/crd/examples/configmapref-for-deno-script.yaml new file mode 100644 index 0000000000..45447b0c08 --- /dev/null +++ b/docs/docs/assets/crd/examples/configmapref-for-deno-script.yaml @@ -0,0 +1,8 @@ +apiVersion: lifecycle.keptn.sh/v1beta1 +kind: KeptnTaskDefinition +metadata: + name: keptntaskdefinition-sample +spec: + deno: + configMapRef: + name: dev-configmap diff --git a/docs/docs/assets/crd/examples/functionref-for-deno-script.yaml b/docs/docs/assets/crd/examples/functionref-for-deno-script.yaml new file mode 100644 index 0000000000..d15a1cd29a --- /dev/null +++ b/docs/docs/assets/crd/examples/functionref-for-deno-script.yaml @@ -0,0 +1,13 @@ +apiVersion: lifecycle.keptn.sh/v1beta1 +kind: KeptnTaskDefinition +metadata: + name: slack-notification-dev +spec: + deno: + functionRef: + name: slack-notification + parameters: + map: + textMessage: "This is my configuration" + secureParameters: + secret: slack-token diff --git a/docs/docs/assets/crd/examples/httpref-script-for-deno-script.yaml b/docs/docs/assets/crd/examples/httpref-script-for-deno-script.yaml new file mode 100644 index 0000000000..659f9c83fd --- /dev/null +++ b/docs/docs/assets/crd/examples/httpref-script-for-deno-script.yaml @@ -0,0 +1,8 @@ +apiVersion: lifecycle.keptn.sh/v1beta1 +kind: KeptnTaskDefinition +metadata: + name: hello-keptn-http +spec: + deno: + httpRef: + url: "https://www.example.com/yourscript.js" diff --git a/docs/docs/assets/crd/examples/inline-script-for-deno-script.yaml b/docs/docs/assets/crd/examples/inline-script-for-deno-script.yaml new file mode 100644 index 0000000000..2d88d90062 --- /dev/null +++ b/docs/docs/assets/crd/examples/inline-script-for-deno-script.yaml @@ -0,0 +1,15 @@ +apiVersion: lifecycle.keptn.sh/v1beta1 +kind: KeptnTaskDefinition +metadata: + name: hello-keptn-inline +spec: + deno: + inline: + code: | + let text = Deno.env.get("DATA"); + let data; + let name; + data = JSON.parse(text); + + name = data.name + console.log("Hello, " + name + " new"); diff --git a/docs/docs/assets/crd/examples/old-version-synopsis.yaml b/docs/docs/assets/crd/examples/old-version-synopsis.yaml new file mode 100644 index 0000000000..cb66606d82 --- /dev/null +++ b/docs/docs/assets/crd/examples/old-version-synopsis.yaml @@ -0,0 +1,10 @@ +apiVersion: metrics.keptn.sh/v1alpha2 +kind: KeptnMetricsProvider +metadata: + name: prometheus | dynatrace |dql + namespace: +spec: + targetServer: "" + secretKeyRef: + name: dt-api-token + key: DT_TOKEN diff --git a/docs/docs/assets/crd/examples/synopsis-for-all-runners.yaml b/docs/docs/assets/crd/examples/synopsis-for-all-runners.yaml new file mode 100644 index 0000000000..4aee3d1db4 --- /dev/null +++ b/docs/docs/assets/crd/examples/synopsis-for-all-runners.yaml @@ -0,0 +1,9 @@ +apiVersion: lifecycle.keptn.sh/v?alpha? +kind: KeptnTaskDefinition +metadata: + name: +spec: | + deno | python | container + ... + retries: + timeout: diff --git a/docs/docs/assets/crd/examples/synopsis-for-container-runtime.yaml b/docs/docs/assets/crd/examples/synopsis-for-container-runtime.yaml new file mode 100644 index 0000000000..22bb64ae08 --- /dev/null +++ b/docs/docs/assets/crd/examples/synopsis-for-container-runtime.yaml @@ -0,0 +1,9 @@ +apiVersion: lifecycle.keptn.sh/v?alpha? +kind: KeptnTaskDefinition +metadata: + name: +spec: + container: | + name: + image: + diff --git a/docs/docs/assets/crd/examples/synopsis-for-deno-runtime-container.yaml b/docs/docs/assets/crd/examples/synopsis-for-deno-runtime-container.yaml new file mode 100644 index 0000000000..db63e41ee8 --- /dev/null +++ b/docs/docs/assets/crd/examples/synopsis-for-deno-runtime-container.yaml @@ -0,0 +1,12 @@ +apiVersion: lifecycle.keptn.sh/v?alpha? +kind: KeptnTaskDefinition +metadata: + name: +spec: + deno: | + inline | httpRef | functionRef | ConfigMapRef + parameters: | + map: + textMessage: "This is my configuration" + secureParameters: + secret: diff --git a/docs/docs/assets/crd/examples/synopsis-for-python-runtime-runner.yaml b/docs/docs/assets/crd/examples/synopsis-for-python-runtime-runner.yaml new file mode 100644 index 0000000000..e52c591480 --- /dev/null +++ b/docs/docs/assets/crd/examples/synopsis-for-python-runtime-runner.yaml @@ -0,0 +1,12 @@ +apiVersion: lifecycle.keptn.sh/v?alpha? +kind: KeptnTaskDefinition +metadata: + name: +spec: + python: | + inline | httpRef | functionRef | ConfigMapRef + parameters: | + map: + textMessage: "This is my configuration" + secureParameters: + secret: diff --git a/docs/docs/assets/crd/examples/yaml-synopsis.yaml b/docs/docs/assets/crd/examples/yaml-synopsis.yaml new file mode 100644 index 0000000000..64cbacbde9 --- /dev/null +++ b/docs/docs/assets/crd/examples/yaml-synopsis.yaml @@ -0,0 +1,12 @@ +apiVersion: metrics.keptn.sh/v1beta1 +kind: KeptnMetricsProvider +metadata: + name: + namespace: +spec: + type: prometheus | dynatrace | dql | datadog + targetServer: "" + secretKeyRef: + name: + key: + optional: true | false diff --git a/docs/docs/reference/crd-reference/metricsprovider.md b/docs/docs/reference/crd-reference/metricsprovider.md index 299638cc4b..c0fda766f5 100644 --- a/docs/docs/reference/crd-reference/metricsprovider.md +++ b/docs/docs/reference/crd-reference/metricsprovider.md @@ -21,18 +21,7 @@ for each metric definition by its name. ## Yaml Synopsis ```yaml -apiVersion: metrics.keptn.sh/v1beta1 -kind: KeptnMetricsProvider -metadata: - name: - namespace: -spec: - type: prometheus | dynatrace | dql | datadog - targetServer: "" - secretKeyRef: - name: - key: - optional: true | false +{% include "../../assets/crd/examples/yaml-synopsis.yaml" %} ``` ## Fields @@ -99,49 +88,51 @@ For detailed information please look at the [Examples section](#examples). ## Examples -### Prometheus + -An example of Prometheus as a metrics provider with a Secret holding -the authentication data looks like the following: +=== "Prometheus" -```yaml -{% include "./assets/keptnmetricsprovider-prometheus.yaml" %} -``` + An example of Prometheus as a metrics provider with a Secret holding + the authentication data looks like the following: -> **Note** -> Setting the `.spec.secretKeyRef.key` field in `KeptnMetricsProvider` is not necessary, -> as `user` and `password` key names are required to be present in the linked Secret. -> Setting this field won't have any effect. + ```yaml + {% include "./assets/keptnmetricsprovider-prometheus.yaml" %} + ``` + > **Note** + Setting the `.spec.secretKeyRef.key` field in `KeptnMetricsProvider` is not necessary, + as `user` and `password` key names are required to be present in the linked Secret. + Setting this field won't have any effect. -### Datadog +=== "Datadog" -An example of Datadog as a metrics provider with a Secret holding -the authentication data looks like the following: + An example of Datadog as a metrics provider with a Secret holding + the authentication data looks like the following: + + ```yaml + {% include "./assets/keptnmetricsprovider-datadog.yaml" %} + ``` + > **Note** + Setting the `.spec.secretKeyRef.key` field in `KeptnMetricsProvider` is not necessary, + as `DD_CLIENT_API_KEY` and `DD_CLIENT_API_KEY` key names must be + present in the linked Secret. + Setting this field has no effect. -```yaml -{% include "./assets/keptnmetricsprovider-datadog.yaml" %} -``` +=== "Dynatrace and DQL" -> **Note** -> Setting the `.spec.secretKeyRef.key` field in `KeptnMetricsProvider` is not necessary, -> as `DD_CLIENT_API_KEY` and `DD_CLIENT_API_KEY` key names must be -> present in the linked Secret. -> Setting this field has no effect. + An example of Dynatrace as a metrics provider with a Secret holding + the authentication data looks like the following: -### Dynatrace and DQL + ```yaml + {% include "./assets/keptnmetricsprovider-dynatrace.yaml" %} + ``` -An example of Dynatrace as a metrics provider with a Secret holding -the authentication data looks like the following: - -```yaml -{% include "./assets/keptnmetricsprovider-dynatrace.yaml" %} -``` + > **Note** + When using Dynatrace as metrics provider you can + define the key name of your DT token stored in a secret, + which is not possible for Datadog or Prometheus. + For this example `myCustomTokenKey` was used. -> **Note** -> When using Dynatrace as metrics provider you can -> define the key name of your DT token stored in a secret, -> which is not possible for Datadog or Prometheus. -> For this example `myCustomTokenKey` was used. + ## Files @@ -164,16 +155,7 @@ only specified the `metadata.name` field that identified the data provider (`prometheus`, `dynatrace`, or `dql`): ```yaml -apiVersion: metrics.keptn.sh/v1alpha2 -kind: KeptnMetricsProvider -metadata: - name: prometheus | dynatrace |dql - namespace: -spec: - targetServer: "" - secretKeyRef: - name: dt-api-token - key: DT_TOKEN +{% include "../../assets/crd/examples/old-version-synopsis.yaml" %} ``` Also note that, for the v1alpha1 and v1alpha2 API versions, diff --git a/docs/docs/reference/crd-reference/taskdefinition.md b/docs/docs/reference/crd-reference/taskdefinition.md index 183261f001..2543651910 100644 --- a/docs/docs/reference/crd-reference/taskdefinition.md +++ b/docs/docs/reference/crd-reference/taskdefinition.md @@ -32,6 +32,7 @@ differentiated by the `spec` section: [Synopsis for container-runtime](#synopsis-for-container-runtime) and [Examples for a container-runtime runner](#examples-for-a-container-runtime-runner). + - Pre-defined containers - Use the pre-defined `deno-runtime` runner @@ -43,16 +44,16 @@ differentiated by the `spec` section: You can use this to specify simple actions without having to define a full container. See - [Synopsis for Deno-runtime container](#deno-runtime) + Synopsis for Deno-runtime container and - [Deno-runtime examples](#examples-for-deno-runtime-runner). + [Deno-runtime examples](#examples-for-deno-runtime-and-python-runtime-runners). - Use the pre-defined `python-runtime` runner to define your task using [Python 3](https://www.python.org/). See - [Synopsis for python-runtime runner](#python-runtime) + Synopsis for python-runtime runner and - [Examples for a python-runtime runner](#examples-for-a-python-runtime-runner). + [Examples for a python-runtime runner](#examples-for-deno-runtime-and-python-runtime-runners). ## Synopsis for all runners @@ -61,15 +62,7 @@ include the same lines at the top. These are described here. ```yaml -apiVersion: lifecycle.keptn.sh/v?alpha? -kind: KeptnTaskDefinition -metadata: - name: -spec: - deno | python | container - ... - retries: - timeout: +{% include "../../assets/crd/examples/synopsis-for-all-runners.yaml" %} ``` ### Fields used for all containers @@ -96,11 +89,11 @@ spec: and code the functionality in Deno script, which is similar to JavaScript and Typescript. See - [Synopsis for deno-runtime container](#deno-runtime) + Synopsis for deno-runtime container - **python** -- Use a `python-runtime` function and code the functionality in Python 3. See - [Synopsis for python-runtime runner](#python-runtime) + Synopsis for python-runtime runner - **container** -- Use the runner defined for the `container-runtime` container. This is a standard Kubernetes container @@ -134,15 +127,7 @@ you can use a `container-runtime` to execute almost anything that you implemented with JES for Keptn v1. ```yaml -apiVersion: lifecycle.keptn.sh/v?alpha? -kind: KeptnTaskDefinition -metadata: - name: -spec: - container: - name: - image: - +{% include "../../assets/crd/examples/synopsis-for-container-runtime.yaml" %} ``` ### Fields used only for container-runtime @@ -163,6 +148,7 @@ spec: [Container](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container) spec documentation. + ## Synopsis for predefined containers The predefined containers allow you to easily define a task @@ -171,52 +157,31 @@ You do not need to specify the image, volumes, and so forth. Instead, just provide either a Deno or Python script and Keptn sets up the container and runs the script as part of the task. -### deno-runtime - -When using the `deno-runtime` runner to define a task, -the executables are coded in -[Deno-script](https://deno.com/manual), -(which is mostly the same as JavaScript and TypeScript) -and executed in the -`deno-runtime` runner, -which is a lightweight runtime environment -that executes in your namespace. -Note that Deno has tighter restrictions -for permissions and importing data -so a script that works properly elsewhere -may not function out of the box when run in the `deno-runtime` runner. +=== "deno-runtime" -```yaml -apiVersion: lifecycle.keptn.sh/v?alpha? -kind: KeptnTaskDefinition -metadata: - name: -spec: - deno: - inline | httpRef | functionRef | ConfigMapRef - parameters: - map: - textMessage: "This is my configuration" - secureParameters: - secret: -``` + When using the `deno-runtime` runner to define a task, + the executables are coded in + [Deno-script](https://deno.com/manual), + (which is mostly the same as JavaScript and TypeScript) + and executed in the + `deno-runtime` runner, + which is a lightweight runtime environment + that executes in your namespace. + Note that Deno has tighter restrictions + for permissions and importing data + so a script that works properly elsewhere + may not function out of the box when run in the `deno-runtime` runner. -### python-runtime + ```yaml + {% include "../../assets/crd/examples/synopsis-for-deno-runtime-container.yaml" %} + ``` -```yaml -apiVersion: lifecycle.keptn.sh/v?alpha? -kind: KeptnTaskDefinition -metadata: - name: -spec: - python: - inline | httpRef | functionRef | ConfigMapRef - parameters: - map: - textMessage: "This is my configuration" - secureParameters: - secret: -``` +=== "python-runtime" + + ```yaml + {% include "../../assets/crd/examples/synopsis-for-python-runtime-runner.yaml" %} + ``` + ### Fields for predefined containers @@ -241,11 +206,13 @@ spec: such as Jenkins, Argo Workflows, Flux, and Tekton. - **deno example:** - [Example 1: inline script for a Deno script](#example-1-inline-script-for-a-deno-script) + Example 1: inline script for a Deno script - **python example:** - [Example 1: inline code for a python-runtime runner](#example-1-inline-code-for-a-python-runtime-runner) + + Example 1: inline code for a python-runtime runner + - **httpRef** - Specify a script to be executed at runtime from the remote webserver that is specified. @@ -260,10 +227,11 @@ spec: Any other scripts listed here are silently ignored. - **deno example:** - [Example 2: httpRef script for a Deno script](#example-2-httpref-script-for-a-deno-script) + Example 2: httpRef script for a Deno script - **python example:** - [Example 2: httpRef for a python-runtime runner](#example-2-httpref-for-a-python-runtime-runner) - + +
+ - **functionRef** -- Execute another `KeptnTaskDefinition` resources. Populate this field with the value(s) of the `metadata.name` field for each `KeptnDefinitionTask` to be called. @@ -290,18 +258,21 @@ spec: are silently ignored. - **deno example:** - [Example 3: functionRef for a Deno script](#example-3-functionref-for-a-deno-script) + Example 3: functionRef for a Deno script - **python example:** - [Example 3: functionRef for a python-runtime runner](#example-3-functionref-for-a-python-runtime-runner) - + + Example 3: functionRef for a python-runtime runner + - **ConfigMapRef** - Specify the name of a [ConfigMap](https://kubernetes.io/docs/concepts/configuration/configmap/) resource that contains the function to be executed. - **deno example:** - [Example 5: ConfigMap for a Deno script](#example-5-configmap-for-a-deno-script) + Example 5: ConfigMap for a Deno script - **python example:** - [Example 4: ConfigMapRef for a python-runtime runner](#example-4-configmapref-for-a-python-runtime-runner) + + Example 4: ConfigMapRef for a python-runtime runner + - **parameters** - An optional field to supply input parameters to a function. @@ -314,9 +285,11 @@ spec: for more information. - **deno example:** - [Example 3: functionRef for a Deno script](#example-3-functionref-for-a-deno-script) + Example 3: functionRef for a Deno script - **python example:** - [Example 3: functionRef for a python-runner runner](#example-3-functionref-for-a-python-runtime-runner) + + Example 3: functionRef for a python-runner runner + - **secureParameters** -- An optional field used to pass a Kubernetes secret. @@ -331,9 +304,11 @@ spec: for details. - **deno example:** - [Example 3: functionRef for a Deno script](#example-3-functionref-for-a-deno-script) + Example 3: functionRef for a Deno script - **python example:** - [Example 3: functionRef for a python-runner runner](#example-3-functionref-for-a-python-runtime-runner) + + Example 3: functionRef for a python-runner runner + ## Usage @@ -396,181 +371,117 @@ This task is then referenced in the [appcontext.yaml](https://github.com/keptn/lifecycle-toolkit/blob/main/examples/sample-app/version-2/appcontext.yaml) file. -## Examples for deno-runtime runner + +## Examples for deno-runtime and python-runtime runners -### Example 1: inline script for a Deno script +### Examples for inline script -This example defines a full-fledged Deno script -within the `KeptnTaskDefinition` YAML file: +=== "Example 1: inline script for a Deno script" -```yaml -apiVersion: lifecycle.keptn.sh/v1beta1 -kind: KeptnTaskDefinition -metadata: - name: hello-keptn-inline -spec: - deno: - inline: - code: | - let text = Deno.env.get("DATA"); - let data; - let name; - data = JSON.parse(text); - - name = data.name - console.log("Hello, " + name + " new"); -``` + This example defines a full-fledged Deno script + within the `KeptnTaskDefinition` YAML file: -### Example 2: httpRef script for a Deno script + ```yaml + {% include "../../assets/crd/examples/inline-script-for-deno-script.yaml" %} + ``` +=== "Example 1: inline code for a python-runtime runner" -This example fetches the Deno script from a remote webserver at runtime: + You can embed python code directly in the task definition. + This example prints data stored in the parameters map: -```yaml -apiVersion: lifecycle.keptn.sh/v1beta1 -kind: KeptnTaskDefinition -metadata: - name: hello-keptn-http -spec: - deno: - httpRef: - url: "https://www.example.com/yourscript.js" -``` + ```yaml + {% include "../../assets/crd/python-inline.yaml" %} + ``` -For another example, see the -[sample-app](https://github.com/keptn-sandbox/lifecycle-toolkit-examples/blob/main/sample-app/version-1/app-pre-deploy.yaml). +### Examples for httpRef script -See the -[sample-app/version-1](https://github.com/keptn-sandbox/lifecycle-toolkit-examples/blob/main/sample-app/version-1/app-pre-deploy.yaml) -PodtatoHead example for a more complete example. +=== "Example 2: httpRef script for a Deno script" -### Example 3: functionRef for a Deno script + This example fetches the Deno script from a remote webserver at runtime: -This example calls another defined task, -illustrating how one `KeptnTaskDefinition` can build -on top of other `KeptnTaskDefinition`s. -In this case, it calls `slack-notification-dev`, -passing `parameters` and `secureParameters` to that other task: + ```yaml + {% include "../../assets/crd/examples/httpref-script-for-deno-script.yaml" %} + ``` -```yaml -apiVersion: lifecycle.keptn.sh/v1beta1 -kind: KeptnTaskDefinition -metadata: - name: slack-notification-dev -spec: - deno: - functionRef: - name: slack-notification - parameters: - map: - textMessage: "This is my configuration" - secureParameters: - secret: slack-token -``` + For another example, see the + [sample-app](https://github.com/keptn-sandbox/lifecycle-toolkit-examples/blob/main/sample-app/version-1/app-pre-deploy.yaml). -### Example 4: ConfigMapRef for a Deno script + See the + [sample-app/version-1](https://github.com/keptn-sandbox/lifecycle-toolkit-examples/blob/main/sample-app/version-1/app-pre-deploy.yaml) + PodtatoHead example for a more complete example. -This example references a `ConfigMap` by the name of `dev-configmap` -that contains the code for the function to be executed. +=== "Example 2: httpRef for a python-runtime runner" -```yaml -apiVersion: lifecycle.keptn.sh/v1beta1 -kind: KeptnTaskDefinition -metadata: - name: keptntaskdefinition-sample -spec: - deno: - configMapRef: - name: dev-configmap -``` + You can refer to code stored online. + For example, we have a few examples available in the + [python-runtime samples](https://github.com/keptn/lifecycle-toolkit/tree/main/runtimes/python-runtime/samples) + tree. -### Example 5: ConfigMap for a Deno script +### Examples for functionRef -This example illustrates the use of both a `ConfigMapRef` and a `ConfigMap`: +=== "Example 3: functionRef for a Deno script" -```yaml -apiVersion: lifecycle.keptn.sh/v1beta1 -kind: KeptnTaskDefinition -metadata: - name: scheduled-deployment -spec: - function: - configMapRef: - name: scheduled-deployment-cm-1 ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: scheduled-deployment-1 -data: - code: | - let text = Deno.env.get("DATA"); - let data; - if (text != "") { - data = JSON.parse(text); - } - let targetDate = new Date(data.targetDate) - let dateTime = new Date(); - if(targetDate < dateTime) { - console.log("Date has passed - ok"); - Deno.exit(0); - } else { - console.log("It's too early - failing"); - Deno.exit(1); - } - console.log(targetDate); -``` + This example calls another defined task, + illustrating how one `KeptnTaskDefinition` can build + on top of other `KeptnTaskDefinition`s. + In this case, it calls `slack-notification-dev`, + passing `parameters` and `secureParameters` to that other task: -### Example 6: Accessing KEPTN_CONTEXT environment variable in a Deno task + ```yaml + {% include "../../assets/crd/examples/functionref-for-deno-script.yaml" %} + ``` -For Tasks triggered as pre- and post- deployment of applications -on Kubernetes, Keptn populates an environment variable called `KEPTN_CONTEXT`. -As all environment variables, this can be accessed using language specific methods. -An example in Deno would be the following: +=== "Example 3: functionRef for a python-runtime runner" -```javascript -let context = Deno.env.get("KEPTN_CONTEXT"); -``` + You can refer to an existing `KeptnTaskDefinition`. + this example calls the inline example + but overrides the data printed with what is specified in the task: -## Examples for a python-runtime runner + ```yaml + {% include "../../assets/crd/python-recursive.yaml" %} + ``` -### Example 1: inline code for a python-runtime runner +### Examples for ConfigMapRef -You can embed python code directly in the task definition. -This example prints data stored in the parameters map: +=== "Example 4: ConfigMapRef for a Deno script" -```yaml -{% include "../../assets/crd/python-inline.yaml" %} -``` + This example references a `ConfigMap` by the name of `dev-configmap` + that contains the code for the function to be executed. -### Example 2: httpRef for a python-runtime runner + ```yaml + {% include "../../assets/crd/examples/configmapref-for-deno-script.yaml" %} + ``` -You can refer to code stored online. -For example, we have a few examples available in the -[python-runtime samples](https://github.com/keptn/lifecycle-toolkit/tree/main/runtimes/python-runtime/samples) -tree. +=== "Example 4: ConfigMapRef for a python-runtime runner" -Consider the following: + ```yaml + {% include "../../assets/crd/python-configmap.yaml" %} + ``` -```yaml -{% include "../../assets/crd/python-configmap.yaml" %} -``` +### Examples for ConfigMap -### Example 3: functionRef for a python-runtime runner +=== "Example 5: ConfigMap for a Deno script" -You can refer to an existing `KeptnTaskDefinition`. -This example calls the inline example -but overrides the data printed with what is specified in the task: + This example illustrates the use of both a `ConfigMapRef` and a `ConfigMap`: -```yaml -{% include "../../assets/crd/python-recursive.yaml" %} -``` + ```yaml + {% include "../../assets/crd/examples/configmap-for-deno-script.yaml" %} + ``` -### Example 4: ConfigMapRef for a python-runtime runner +### Example for Accessing KEPTN_CONTEXT environment variable -```yaml -{% include "../../assets/crd/python-configmap.yaml" %} -``` +=== "Example 6: Accessing KEPTN_CONTEXT environment variable in a Deno task" + + For Tasks triggered as pre- and post- deployment of applications + on Kubernetes, Keptn populates an environment variable called `KEPTN_CONTEXT`. + As all environment variables, this can be accessed using language specific methods. + An example in Deno would be the following: + + ```javascript + let context = Deno.env.get("KEPTN_CONTEXT"); + ``` + ### Allowed libraries for the python-runtime runner The following example shows how to use some of the allowed packages, namely: diff --git a/mkdocs.yml b/mkdocs.yml index 6dca2803e2..53b2f69b1c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -87,6 +87,11 @@ markdown_extensions: - name: mermaid class: mermaid format: !!python/name:pymdownx.superfences.fence_code_format + - pymdownx.tabbed: + alternate_style: true + slugify: !!python/object/apply:pymdownx.slugs.slugify + kwds: + case: lower nav: - Home: