From c8131b63b55fc11085a7ab83b555b077656d9a7a Mon Sep 17 00:00:00 2001 From: Giovanni Liva Date: Fri, 21 Apr 2023 10:07:14 +0200 Subject: [PATCH] docs: adding KLT runtime info for local development (#1246) Signed-off-by: Giovanni Liva Co-authored-by: Florian Bacher --- functions-runtime/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/functions-runtime/README.md b/functions-runtime/README.md index 55f0194419..134c28b638 100644 --- a/functions-runtime/README.md +++ b/functions-runtime/README.md @@ -8,6 +8,30 @@ docker build -t keptnsandbox/klc-runtime:${VERSION} . ## Usage +The Keptn function runtime uses [Deno](https://deno.land/) +to execute Javascript/Typescript code. +The Keptn Lifecycle Toolkit uses this runtime to run [KeptnTask](https://lifecycle.keptn.sh/docs/tasks/write-tasks/) +for pre- and post-checks. +The Keptn Lifecycle Toolkit passes parameters of `KeptnTask`s and +[Context](https://lifecycle.keptn.sh/docs/concepts/tasks/#context) information +to the runtime via the special environmental variable `DATA`. +It also supports mounting Kubernetes secrets making them accessible via the `SECURE_DATA` env var. +You can then read the data with the following snippet of code. + +```js +const data = Deno.env.get("DATA")!; +const secret = Deno.env.get("SECURE_DATA")!; +console.log(data); +console.log(secret); +``` + +`KeptnTask`s can be tested locally with the runtime using the following command. +Replace `${VERSION}` with the KLT version of your choice. + +```sh +docker run -v $(pwd)/test.ts:/test.ts -e SCRIPT=/test.ts -e DATA='{ "url":"http://localhost:9090" }' -e SECURE_DATA='{ "token": "myToken"}' -it ghcr.io/keptn/functions-runtime:${VERSION} +``` + ### Docker with function on webserver (function in this repo) ```shell