Skip to content

Commit

Permalink
docs: adding KLT runtime info for local development (#1246)
Browse files Browse the repository at this point in the history
Signed-off-by: Giovanni Liva <giovanni.liva@dynatrace.com>
Co-authored-by: Florian Bacher <florian.bacher@dynatrace.com>
  • Loading branch information
thisthat and bacherfl committed Apr 21, 2023
1 parent 497e57e commit c8131b6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions functions-runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c8131b6

Please sign in to comment.