From 396c8cf2ec34ecd41f1f019ffe58829109bfb79a Mon Sep 17 00:00:00 2001 From: Elliot Gunton Date: Wed, 26 Apr 2023 15:32:50 +0100 Subject: [PATCH] Add global_parameters upstream example (#596) Prepping example for #595, will make the changes to improve the Hera syntax in another PR Signed-off-by: Elliot Gunton --- .../workflows/upstream/global_parameters.md | 48 +++++++++++++++++++ .../upstream/global-parameters.upstream.yaml | 20 ++++++++ .../workflows/upstream/global-parameters.yaml | 18 +++++++ .../workflows/upstream/global_parameters.py | 13 +++++ 4 files changed, 99 insertions(+) create mode 100644 docs/examples/workflows/upstream/global_parameters.md create mode 100644 examples/workflows/upstream/global-parameters.upstream.yaml create mode 100644 examples/workflows/upstream/global-parameters.yaml create mode 100644 examples/workflows/upstream/global_parameters.py diff --git a/docs/examples/workflows/upstream/global_parameters.md b/docs/examples/workflows/upstream/global_parameters.md new file mode 100644 index 000000000..b19f6d548 --- /dev/null +++ b/docs/examples/workflows/upstream/global_parameters.md @@ -0,0 +1,48 @@ +# Global Parameters + +> Note: This example is a replication of an Argo Workflow example in Hera. The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/master/examples/global-parameters.yaml). + + + + +=== "Hera" + + ```python linenums="1" + from hera.workflows import Container, Parameter, Workflow + + with Workflow( + generate_name="global-parameters-", + entrypoint="whalesay1", + arguments=Parameter(name="message", value="hello world"), + ) as w: + Container( + name="whalesay1", + image="docker/whalesay:latest", + command=["cowsay"], + args=["{{workflow.parameters.message}}"], + ) + ``` + +=== "YAML" + + ```yaml linenums="1" + apiVersion: argoproj.io/v1alpha1 + kind: Workflow + metadata: + generateName: global-parameters- + spec: + arguments: + parameters: + - name: message + value: hello world + entrypoint: whalesay1 + templates: + - container: + args: + - '{{workflow.parameters.message}}' + command: + - cowsay + image: docker/whalesay:latest + name: whalesay1 + ``` + diff --git a/examples/workflows/upstream/global-parameters.upstream.yaml b/examples/workflows/upstream/global-parameters.upstream.yaml new file mode 100644 index 000000000..179a61b7e --- /dev/null +++ b/examples/workflows/upstream/global-parameters.upstream.yaml @@ -0,0 +1,20 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: global-parameters- +spec: + entrypoint: whalesay1 + # Parameters can be passed/overridden via the argo CLI. + # To override the printed message, run `argo submit` with the -p option: + # $ argo submit examples/arguments-parameters.yaml -p message="goodbye world" + arguments: + parameters: + - name: message + value: hello world + + templates: + - name: whalesay1 + container: + image: docker/whalesay:latest + command: [cowsay] + args: ["{{workflow.parameters.message}}"] diff --git a/examples/workflows/upstream/global-parameters.yaml b/examples/workflows/upstream/global-parameters.yaml new file mode 100644 index 000000000..4bc535387 --- /dev/null +++ b/examples/workflows/upstream/global-parameters.yaml @@ -0,0 +1,18 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: global-parameters- +spec: + arguments: + parameters: + - name: message + value: hello world + entrypoint: whalesay1 + templates: + - container: + args: + - '{{workflow.parameters.message}}' + command: + - cowsay + image: docker/whalesay:latest + name: whalesay1 diff --git a/examples/workflows/upstream/global_parameters.py b/examples/workflows/upstream/global_parameters.py new file mode 100644 index 000000000..94d4bcba0 --- /dev/null +++ b/examples/workflows/upstream/global_parameters.py @@ -0,0 +1,13 @@ +from hera.workflows import Container, Parameter, Workflow + +with Workflow( + generate_name="global-parameters-", + entrypoint="whalesay1", + arguments=Parameter(name="message", value="hello world"), +) as w: + Container( + name="whalesay1", + image="docker/whalesay:latest", + command=["cowsay"], + args=["{{workflow.parameters.message}}"], + )