From 8dd6f4475a1d059bad29d54456259c7e848f79cc Mon Sep 17 00:00:00 2001 From: Jonathan Michaux <5730842+jmcx@users.noreply.github.com> Date: Tue, 6 Jun 2023 10:47:28 +0200 Subject: [PATCH] Minor updates and fixes to functions docs (#385) --- docs/transformation/functions/index.md | 14 ++++++++++++++ docs/transformation/functions/nodejsfunctions.md | 2 ++ docs/transformation/functions/pythonfunctions.md | 7 +++++-- docs/transformation/functions/rubyfunctions.md | 2 ++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/transformation/functions/index.md b/docs/transformation/functions/index.md index 1df9c5b53..6a322d9e0 100644 --- a/docs/transformation/functions/index.md +++ b/docs/transformation/functions/index.md @@ -8,3 +8,17 @@ For low-code style transformations in JSON, refer to [JSON Transformation](../js TriggerMesh functions with `tmctl` is a work in progress and not currently supported. Furthermore, note that TriggerMesh Functions are opinionated and simple. They are aimed to be used for event transformation and do not support external dependencies. Functions that may need external dependencies are best served with something like AWS Lambda or [Knative Functions](https://knative.dev/docs/functions/). + +See the [Kubernetes object reference](../../reference/extensions/#extensions.triggermesh.io/v1alpha1.Function) for the Function reference docs. + +## Common function configuration options + +Below are some parameters you can configure in the function CRD, that apply to all function runtimes. + +| Parameter | Description | +| ------------------------- | ------------------------------------------------------------ | +| `adapterOverrides.public` | Boolean. If true, function will be allocated a public URL so that it can be accessed from outside the cluster. Default is false. | +| `ceOverrides.extensions` | Can be used to modify the values of CloudEvents attributes in the event return by the function back to the caller. | +| `responseIsEvent` | Boolean. If false, the function will wrap what is returned by the function into the `data` attribute of a CloudEvent and respond back to the caller with it. It will add default CloudEvent metadata attributes, unless values are overriden in `ceOverrides`. If true, expects the user to have returned a complete CloudEvent object, and will no wrap it into the `data` attribute of a new CloudEvent. | +| `entrypoint` | Name of the function to be used as an entry point in the code. | +| `runtime` | Currently supported runtime values are `python`, `node`, and `ruby`. | \ No newline at end of file diff --git a/docs/transformation/functions/nodejsfunctions.md b/docs/transformation/functions/nodejsfunctions.md index 77d7023a7..4459fa968 100644 --- a/docs/transformation/functions/nodejsfunctions.md +++ b/docs/transformation/functions/nodejsfunctions.md @@ -1,5 +1,7 @@ # NodeJS functions +For information about configuration options across all function runtimes, please head to the [main functions documentation page](index.md). + ## NodeJS empty field transformation example on Kubernetes ```yaml diff --git a/docs/transformation/functions/pythonfunctions.md b/docs/transformation/functions/pythonfunctions.md index 0e8b877bb..fc3436fd2 100644 --- a/docs/transformation/functions/pythonfunctions.md +++ b/docs/transformation/functions/pythonfunctions.md @@ -25,11 +25,14 @@ metadata: name: python-function-hello spec: runtime: python - public: true + adapterOverrides: + public: true entrypoint: endpoint code: | + import json def endpoint(event, context): - return "Hello " + event['name'] + jsonEvent = json.loads(event) + return "Hello " + jsonEvent['name'] ``` You can then create the function with: diff --git a/docs/transformation/functions/rubyfunctions.md b/docs/transformation/functions/rubyfunctions.md index 9eabe626a..ae8c6afd0 100644 --- a/docs/transformation/functions/rubyfunctions.md +++ b/docs/transformation/functions/rubyfunctions.md @@ -1,5 +1,7 @@ # Ruby functions +For information about configuration options across all function runtimes, please head to the [main functions documentation page](index.md). + ## Ruby date and time event example on Kubernetes ```YAML