From c8f3a5d111191c783fc59b23c2769aa544f9c1cf Mon Sep 17 00:00:00 2001 From: Mengqi Yu Date: Wed, 26 May 2021 16:22:44 -0700 Subject: [PATCH] address comments --- examples/apply-setters/simple/README.md | 10 ++- examples/contrib/analyze-istio/README.md | 4 +- examples/contrib/inflate-helm-chart/README.md | 6 +- examples/contrib/sops/age/README.md | 4 +- examples/contrib/sops/gpg/README.md | 4 +- .../invalid-configmap/README.md | 8 +-- .../enforce-gatekeeper/warning-only/README.md | 4 +- .../ensure-name-substring/advanced/README.md | 6 +- .../ensure-name-substring/prefix/README.md | 8 +-- .../ensure-name-substring/suffix/README.md | 8 +-- examples/fix/simple/README.md | 6 +- examples/format/imperative/README.md | 6 +- .../kubeval/simple/.expected/results.yaml | 11 ---- examples/kubeval/simple/Kptfile | 1 + examples/kubeval/simple/README.md | 63 +++++++++++-------- .../search-replace/create-setters/README.md | 14 ++--- examples/search-replace/simple/README.md | 10 ++- examples/set-annotations/advanced/README.md | 6 +- examples/set-annotations/simple/README.md | 8 +-- examples/set-labels/advanced/README.md | 6 +- examples/set-labels/simple/README.md | 8 +-- examples/set-namespace/advanced/README.md | 8 +-- examples/set-namespace/simple/README.md | 8 +-- examples/starlark/simple/README.md | 6 +- examples/upsert-resource/simple/README.md | 9 +-- functions/contrib/ts/sops/README.md | 6 +- functions/go/apply-setters/README.md | 4 +- functions/go/fix/README.md | 2 +- functions/go/search-replace/README.md | 14 ++--- tests/e2e.sh | 3 +- 30 files changed, 131 insertions(+), 130 deletions(-) diff --git a/examples/apply-setters/simple/README.md b/examples/apply-setters/simple/README.md index 9e5d68588..cee0bc966 100644 --- a/examples/apply-setters/simple/README.md +++ b/examples/apply-setters/simple/README.md @@ -2,8 +2,6 @@ ### Overview - - Setters provide a solution for template-free setting of field values. The `apply-setters` KRM config function applies setter values to resource fields with setter references. @@ -27,7 +25,7 @@ environments: # kpt-set: ${env} - stage ``` -We use ConfigMap to configure the `apply-setters` function. The desired +We use `ConfigMap` to configure the `apply-setters` function. The desired setter values are provided as key-value pairs using `data` field where key is the name of the setter(as seen in the reference comments) and value is the new desired value for the tagged field. @@ -67,9 +65,9 @@ environments: # kpt-set: ${env} Get the config example and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/apply-setters/simple . -kpt fn render simple +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/apply-setters/simple . +$ kpt fn render simple ``` ### Expected result diff --git a/examples/contrib/analyze-istio/README.md b/examples/contrib/analyze-istio/README.md index d2bee6400..3c62aa750 100644 --- a/examples/contrib/analyze-istio/README.md +++ b/examples/contrib/analyze-istio/README.md @@ -9,7 +9,7 @@ declarative configuration. Get this example and try it out by running the following commands: -```sh +```shell kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/contrib/analyze-istio . kpt fn run analyze-istio ``` @@ -18,7 +18,7 @@ kpt fn run analyze-istio This should give the following output: -```sh +```shell [ERROR] Schema validation error: gateway must have at least one server in object 'networking.istio.io/v1alpha3/Gateway//httpbin-gateway' in file example-config.yaml error: exit status 1 ``` diff --git a/examples/contrib/inflate-helm-chart/README.md b/examples/contrib/inflate-helm-chart/README.md index 8b108e8c2..9e6686bcd 100644 --- a/examples/contrib/inflate-helm-chart/README.md +++ b/examples/contrib/inflate-helm-chart/README.md @@ -8,7 +8,7 @@ declarative configuration. Get this example and try it out by running the following commands: -```sh +```shell kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/contrib/inflate-helm-chart . kpt fn run --as-current-user inflate-helm-chart/local-configs --mount type=bind,src=$(pwd)/inflate-helm-chart/helloworld-chart,dst=/source ``` @@ -17,7 +17,7 @@ kpt fn run --as-current-user inflate-helm-chart/local-configs --mount type=bind, Checking the contents of the `local-configs` directory with `kpt cfg tree inflate-helm-chart/local-configs/` should reveal the following new yaml files: -```sh +```shell inflate-helm-chart/local-configs ├── [deployment_chart-helloworld-chart.yaml] Deployment chart-helloworld-chart ├── [fn-config.yaml] ConfigMap my-func-config @@ -28,7 +28,7 @@ inflate-helm-chart/local-configs To view changes without writing them into a file, a dry run can be performed as follows: -```sh +```shell kpt fn run --as-current-user inflate-helm-chart/local-configs --mount type=bind,src=$(pwd)/inflate-helm-chart/helloworld-chart,dst=/source --dry-run ``` diff --git a/examples/contrib/sops/age/README.md b/examples/contrib/sops/age/README.md index cf66390d6..2eb8c3871 100644 --- a/examples/contrib/sops/age/README.md +++ b/examples/contrib/sops/age/README.md @@ -10,7 +10,7 @@ This example demonstrates invocation of `sops` for encryption the resouce called Get this example and try it out by running the following commands: -```sh +```shell # download this example kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/contrib/sops/age . @@ -25,7 +25,7 @@ SOPS_IMPORT_AGE="$(cat age_keys.txt)" kpt fn run age Verify the updated configuration: -```sh +```shell kpt cfg cat age ``` diff --git a/examples/contrib/sops/gpg/README.md b/examples/contrib/sops/gpg/README.md index e4569bd7d..19920a021 100644 --- a/examples/contrib/sops/gpg/README.md +++ b/examples/contrib/sops/gpg/README.md @@ -10,7 +10,7 @@ This example demonstrates invocation of `sops` for encryption the resouce called Get this example and try it out by running the following commands: -```sh +```shell # download this example kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/contrib/sops/gpg . @@ -25,7 +25,7 @@ SOPS_IMPORT_PGP="$(cat gpg_keys.asc)" kpt fn run gpg Verify the updated configuration: -```sh +```shell kpt cfg cat gpg ``` diff --git a/examples/enforce-gatekeeper/invalid-configmap/README.md b/examples/enforce-gatekeeper/invalid-configmap/README.md index ed5f0243d..de2d9f907 100644 --- a/examples/enforce-gatekeeper/invalid-configmap/README.md +++ b/examples/enforce-gatekeeper/invalid-configmap/README.md @@ -5,9 +5,9 @@ This example demonstrates how to declaratively run the [enforce-gatekeeper] function to validate resources using gatekeeper constraints. -There are 3 resources: a ConstraintTemplate, a K8sBannedConfigMapKeysV1 and a -ConfigMap. -The constraint disallows using `private_key` as a key in the ConfigMap. +There are 3 resources: a `ConstraintTemplate`, a `K8sBannedConfigMapKeysV1` and +a `ConfigMap`. +The constraint disallows using `private_key` as a key in the `ConfigMap`. Here's an example Kptfile to run the function: ```yaml @@ -72,7 +72,7 @@ You can find: - what constraint does it violate - where does the resource live and its index in the file -To pass validation, let's replace the key `private_key` in the ConfigMap in +To pass validation, let's replace the key `private_key` in the `ConfigMap` in `resources.yaml` with something else e.g. `public_key`. Rerun the command. It will succeed. diff --git a/examples/enforce-gatekeeper/warning-only/README.md b/examples/enforce-gatekeeper/warning-only/README.md index 2e98b1415..0d25e8dfb 100644 --- a/examples/enforce-gatekeeper/warning-only/README.md +++ b/examples/enforce-gatekeeper/warning-only/README.md @@ -6,7 +6,7 @@ This example demonstrates how to declaratively run the [enforce-gatekeeper] function to validate resources using gatekeeper constraints. The violations are configured to be warnings instead of errors. -Here's an example Kptfile to run the function: +Here's an example `Kptfile` to run the function: ```yaml apiVersion: kpt.dev/v1alpha2 @@ -80,7 +80,7 @@ You can find: - what constraint does it violate - where does the resource live and its index in the file -To pass validation, let's replace the key `private_key` in the ConfigMap in +To pass validation, let's replace the key `private_key` in the `ConfigMap` in `resources.yaml` with something else e.g. `public_key`. Rerun the command. It will no longer have the warning. diff --git a/examples/ensure-name-substring/advanced/README.md b/examples/ensure-name-substring/advanced/README.md index 009773d4d..fe27a8eaf 100644 --- a/examples/ensure-name-substring/advanced/README.md +++ b/examples/ensure-name-substring/advanced/README.md @@ -41,9 +41,9 @@ The function will not only update field `.metadata.name` but also field Get the config example and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/ensure-name-substring/advanced . -kpt fn render advanced +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/ensure-name-substring/advanced . +$ kpt fn render advanced ``` ### Expected result diff --git a/examples/ensure-name-substring/prefix/README.md b/examples/ensure-name-substring/prefix/README.md index 6cfe18b85..0ddc63824 100644 --- a/examples/ensure-name-substring/prefix/README.md +++ b/examples/ensure-name-substring/prefix/README.md @@ -5,7 +5,7 @@ This example demonstrates how to declaratively run the [`ensure-name-substring`] function to prepend prefix in the resource names. -We use the following Kptfile to run the function. +We use the following `Kptfile` to run the function. ```yaml apiVersion: kpt.dev/v1alpha2 @@ -25,9 +25,9 @@ We are going to prepend prefix `prod-` to resource names. Get the config example and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/ensure-name-substring/prefix . -kpt fn render prefix +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/ensure-name-substring/prefix . +$ kpt fn render prefix ``` ### Expected result diff --git a/examples/ensure-name-substring/suffix/README.md b/examples/ensure-name-substring/suffix/README.md index 6e51ec1cf..4ded3d4df 100644 --- a/examples/ensure-name-substring/suffix/README.md +++ b/examples/ensure-name-substring/suffix/README.md @@ -5,7 +5,7 @@ This example demonstrates how to declaratively run the [`ensure-name-substring`] function to append suffix in the resource names. -We use the following Kptfile to run the function. +We use the following `Kptfile` to run the function. ```yaml apiVersion: kpt.dev/v1alpha2 @@ -25,9 +25,9 @@ We are going to append suffix `-prod` to resource names. Get the config example and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/ensure-name-substring/suffix . -kpt fn render suffix +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/ensure-name-substring/suffix . +$ kpt fn render suffix ``` ### Expected result diff --git a/examples/fix/simple/README.md b/examples/fix/simple/README.md index dd21ab0e1..bdbf06113 100644 --- a/examples/fix/simple/README.md +++ b/examples/fix/simple/README.md @@ -84,9 +84,9 @@ The transformed package is compatible with kpt 1.0 binary. Get the config example and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/fix/simple . -kpt fn eval simple --image gcr.io/kpt-fn/fix:unstable --include-meta-resources +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/fix/simple . +$ kpt fn eval simple --image gcr.io/kpt-fn/fix:unstable --include-meta-resources ``` ### Expected result diff --git a/examples/format/imperative/README.md b/examples/format/imperative/README.md index 1d3ee633d..08d12d97c 100644 --- a/examples/format/imperative/README.md +++ b/examples/format/imperative/README.md @@ -11,9 +11,9 @@ This example depicts the functionality of `format` function by formatting a Get the config example and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/format/imperative . -kpt fn eval imperative --image=gcr.io/kpt-fn/format:unstable +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/format/imperative . +$ kpt fn eval imperative --image=gcr.io/kpt-fn/format:unstable ``` ## Expected result diff --git a/examples/kubeval/simple/.expected/results.yaml b/examples/kubeval/simple/.expected/results.yaml index cfa163d43..47958920b 100644 --- a/examples/kubeval/simple/.expected/results.yaml +++ b/examples/kubeval/simple/.expected/results.yaml @@ -7,17 +7,6 @@ items: - image: gcr.io/kpt-fn/kubeval:unstable exitCode: 1 results: - - message: | - Validating arbitrary CRDs is not supported yet. You can skip them by setting ignore_missing_schemas or skip_kinds in the function config: - ERR - stdin: Failed initializing schema file:///tmp/master-standalone-strict/mycustom-example-v1.json: open /tmp/master-standalone-strict/mycustom-example-v1.json: no such file or directory - severity: error - resourceRef: - apiVersion: example.com/v1 - kind: MyCustom - name: alice - file: - path: resources.yaml - index: 1 - message: Additional property templates is not allowed severity: error resourceRef: diff --git a/examples/kubeval/simple/Kptfile b/examples/kubeval/simple/Kptfile index 146f8c5c5..38ea44f49 100644 --- a/examples/kubeval/simple/Kptfile +++ b/examples/kubeval/simple/Kptfile @@ -7,3 +7,4 @@ pipeline: - image: gcr.io/kpt-fn/kubeval:unstable configMap: strict: 'true' + skip_kinds: MyCustom diff --git a/examples/kubeval/simple/README.md b/examples/kubeval/simple/README.md index 2d4f01b3d..3d2c32fb2 100644 --- a/examples/kubeval/simple/README.md +++ b/examples/kubeval/simple/README.md @@ -19,47 +19,60 @@ pipeline: strict: 'true' ``` -The function configuration is provided using a ConfigMap. We set 1 key-value -pair: +The function configuration is provided using a `ConfigMap`. We set 2 key-value +pairs: - `strict: 'true'`: We disallow unknown fields. +- `skip_kinds: MyCustom`: We skip resources of kind `MyCustom`. ### Function invocation Get this example and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/kubeval/simple . -kpt fn render simple +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/kubeval/simple . +$ kpt fn render simple --results-dir=/tmp ``` ### Expected Results -This should give the following output: +Let's take a look at the structured results in `/tmp/results.yaml`: -```sh -Package "simple": - -[RUNNING] "gcr.io/kpt-fn/kubeval:unstable" -[FAIL] "gcr.io/kpt-fn/kubeval:unstable" - Stderr: - "[ERROR] Additional property templates is not allowed in object 'v1/ReplicationController//bob' in file resources.yaml in field templates" - "[ERROR] Invalid type. Expected: [integer,null], given: string in object 'v1/ReplicationController//bob' in file resources.yaml in field spec.replicas" - "" - Exit Code: 1 +```yaml +apiVersion: kpt.dev/v1alpha2 +kind: FunctionResultList +metadata: + name: fnresults +exitCode: 1 +items: + - image: gcr.io/kpt-fn/kubeval:unstable + exitCode: 1 + results: + - message: Additional property templates is not allowed + severity: error + resourceRef: + apiVersion: v1 + kind: ReplicationController + name: bob + field: + path: templates + file: + path: resources.yaml + - message: 'Invalid type. Expected: [integer,null], given: string' + severity: error + resourceRef: + apiVersion: v1 + kind: ReplicationController + name: bob + field: + path: spec.replicas + file: + path: resources.yaml ``` There are validation error in the `resources.yaml` file, to fix them: - replace the value of `spec.replicas` with an integer - change `templates` to `template` -Rerun the command, and it should output like the following: -```sh -Package "simple": - -[RUNNING] "gcr.io/kpt-fn/kubeval:unstable" -[PASS] "gcr.io/kpt-fn/kubeval:unstable" - -Successfully executed 1 function(s) in 1 package(s). -``` +Rerun the command, and it should succeed now. [`kubeval`]: https://catalog.kpt.dev/kubeval/v0.1/ diff --git a/examples/search-replace/create-setters/README.md b/examples/search-replace/create-setters/README.md index 19b9070fb..0801d7c89 100644 --- a/examples/search-replace/create-setters/README.md +++ b/examples/search-replace/create-setters/README.md @@ -25,19 +25,19 @@ spec: Get the config example: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/search-replace/create-setters . +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/search-replace/create-setters . ``` Suppose you want to expose the values of `image` and `tag` as parameters. You can create [setters] by invoking `search-replace` function with following arguments: -```sh -kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- 'by-path=spec.replicas' 'put-comment=kpt-set: ${replicas}' +```shell +$ kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- 'by-path=spec.replicas' 'put-comment=kpt-set: ${replicas}' ``` -```sh -kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- 'by-path=spec.**.image' 'put-comment=kpt-set: gcr.io/${image}:${tag}' +```shell +$ kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- 'by-path=spec.**.image' 'put-comment=kpt-set: gcr.io/${image}:${tag}' ``` ### Expected result @@ -61,7 +61,7 @@ spec: Next, you can try to run the `apply-setters` function to use the [setters] that you just created. For example: ```shell -kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- replicas=3 image=nginx tag=1.14.2 +$ kpt fn eval --image gcr.io/kpt-fn/search-replace:unstable -- replicas=3 image=nginx tag=1.14.2 ``` You should be able to see the values got updated by the [setters]. diff --git a/examples/search-replace/simple/README.md b/examples/search-replace/simple/README.md index 91d7a5ed0..825f3be82 100644 --- a/examples/search-replace/simple/README.md +++ b/examples/search-replace/simple/README.md @@ -2,8 +2,6 @@ ### Overview - - The `search-replace` function performs search and optionally replace fields across all resources. @@ -22,7 +20,7 @@ metadata: Search matchers are provided with `by-` prefix. When multiple matchers are provided they are AND’ed together. `put-` matchers are mutually exclusive. -We use the following ConfigMap to provide input matchers to the function. +We use the following `ConfigMap` to provide input matchers to the function. ```yaml apiVersion: v1 @@ -49,9 +47,9 @@ metadata: Get the config example and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/search-replace/simple . -kpt fn render simple +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/search-replace/simple . +$ kpt fn render simple ``` ### Expected result diff --git a/examples/set-annotations/advanced/README.md b/examples/set-annotations/advanced/README.md index a304d4ac8..2586e6d93 100644 --- a/examples/set-annotations/advanced/README.md +++ b/examples/set-annotations/advanced/README.md @@ -44,9 +44,9 @@ specify it in field `fieldSpecs`. Get the example config and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-annotations/advanced . -kpt fn render advanced +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-annotations/advanced . +$ kpt fn render advanced ``` ### Expected result diff --git a/examples/set-annotations/simple/README.md b/examples/set-annotations/simple/README.md index 202c67a79..5e2758446 100644 --- a/examples/set-annotations/simple/README.md +++ b/examples/set-annotations/simple/README.md @@ -20,15 +20,15 @@ pipeline: fruit: apple ``` -The desired annotations are provided as key-value pairs through ConfigMap. +The desired annotations are provided as key-value pairs through `ConfigMap`. ### Function invocation Get the example config and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-annotations/simple . -kpt fn render simple +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-annotations/simple . +$ kpt fn render simple ``` ### Expected result diff --git a/examples/set-labels/advanced/README.md b/examples/set-labels/advanced/README.md index 2488e46bb..4ef0d7a01 100644 --- a/examples/set-labels/advanced/README.md +++ b/examples/set-labels/advanced/README.md @@ -44,9 +44,9 @@ added to field `.spec.selector.labels` as well. We specify it in field Get the example config and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-labels/advanced . -kpt fn render advanced +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-labels/advanced . +$ kpt fn render advanced ``` ### Expected result diff --git a/examples/set-labels/simple/README.md b/examples/set-labels/simple/README.md index 70a2c1b35..ed32bb005 100644 --- a/examples/set-labels/simple/README.md +++ b/examples/set-labels/simple/README.md @@ -20,15 +20,15 @@ pipeline: fruit: apple ``` -The desired labels are provided as key-value pairs through ConfigMap. +The desired labels are provided as key-value pairs through `ConfigMap`. ### Function invocation Get the example config and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-labels/simple . -kpt fn render simple +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-labels/simple . +$ kpt fn render simple ``` ### Expected result diff --git a/examples/set-namespace/advanced/README.md b/examples/set-namespace/advanced/README.md index d75daa9f8..b6812489c 100644 --- a/examples/set-namespace/advanced/README.md +++ b/examples/set-namespace/advanced/README.md @@ -34,7 +34,7 @@ fieldSpecs: create: true ``` -`set-namespace` function not only support ConfigMap but also a CRD as the +`set-namespace` function not only support `ConfigMap` but also a CRD as the function configuration. We embed the CRD in the `Kptfile` in this example. The desired namespace is provided using `.namespace` field in the function configuration. @@ -47,9 +47,9 @@ Suppose we have a CRD with group `dev.example.com`, version `v1` and kind Get the example config and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-namespace/advanced . -kpt fn render advanced +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-namespace/advanced . +$ kpt fn render advanced ``` ### Expected result diff --git a/examples/set-namespace/simple/README.md b/examples/set-namespace/simple/README.md index bb9286728..e3e3223b1 100644 --- a/examples/set-namespace/simple/README.md +++ b/examples/set-namespace/simple/README.md @@ -20,7 +20,7 @@ pipeline: namespace: example-ns ``` -The function configuration is provided using a ConfigMap. We set only one +The function configuration is provided using a `ConfigMap`. We set only one key-value pair: - `namespace: example-ns`: The desired namespace. @@ -28,9 +28,9 @@ key-value pair: Get the config example and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-namespace/simple . -kpt fn render simple +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/set-namespace/simple . +$ kpt fn render simple ``` ### Expected result diff --git a/examples/starlark/simple/README.md b/examples/starlark/simple/README.md index d8adf2a0b..d490adc48 100644 --- a/examples/starlark/simple/README.md +++ b/examples/starlark/simple/README.md @@ -43,9 +43,9 @@ to `prod` for all resources. Get the config example and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/starlark/simple . -kpt fn render simple +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/starlark/simple . +$ kpt fn render simple ``` ### Expected result diff --git a/examples/upsert-resource/simple/README.md b/examples/upsert-resource/simple/README.md index 42b2cbf84..d457b2bf9 100644 --- a/examples/upsert-resource/simple/README.md +++ b/examples/upsert-resource/simple/README.md @@ -1,7 +1,8 @@ # upsert-resource: Simple Example In this example, we will see how `upsert-resource` function replaces the -matching resource(identified by GKNN) in the package with the input resource. +matching resource (identified by GKNN (Group, Kind, Namespace and Name)) in the +package with the input resource. Let's start with the list of resources in a package: @@ -62,9 +63,9 @@ spec: Get the config example and try it out by running the following commands: -```sh -kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/upsert-resource/simple . -kpt fn render simple +```shell +$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/upsert-resource/simple . +$ kpt fn render simple ``` ### Expected result diff --git a/functions/contrib/ts/sops/README.md b/functions/contrib/ts/sops/README.md index 6f7ca0ea5..9cd87bb51 100644 --- a/functions/contrib/ts/sops/README.md +++ b/functions/contrib/ts/sops/README.md @@ -40,19 +40,19 @@ make possible to work with PGP and AGE encryption. For `pgp` if you have a file with keys it's possible to run: -```sh +```shell SOPS_IMPORT_PGP="$(cat .asc)" kpt fn run ``` or if your keys are already presented in `gpg`-storage, it's possible to run: -```sh +```shell SOPS_IMPORT_PGP="$(gpg --armor --export-secret-keys)" kpt fn run ``` To make `sops` decrypt `age` it's necessary to keep all keys in the single file `~/.config/sops/age/keys.txt`. If that file exists, it's possible to invoke sops function and provide it with that keys by the command: -```sh +```shell SOPS_IMPORT_AGE="$(cat ~/.config/sops/age/keys.txt)" kpt fn run ``` diff --git a/functions/go/apply-setters/README.md b/functions/go/apply-setters/README.md index d178b72b0..5bf73894f 100644 --- a/functions/go/apply-setters/README.md +++ b/functions/go/apply-setters/README.md @@ -64,13 +64,13 @@ data: Render the declared values by invoking: -```sh +```shell $ kpt fn run --image gcr.io/kpt-fn/apply-setters:unstable --fn-config ./apply-setters-fn-config ``` Alternatively, setter values can be passed as key-value pairs in the CLI -```sh +```shell $ kpt fn run --image gcr.io/kpt-fn/apply-setters:unstable -- 'image=ubuntu' 'replicas=3' ``` diff --git a/functions/go/fix/README.md b/functions/go/fix/README.md index ac41621e5..eed629021 100644 --- a/functions/go/fix/README.md +++ b/functions/go/fix/README.md @@ -84,7 +84,7 @@ openAPI: Invoke `fix` function on the package: -```sh +```shell $ kpt fn eval --image gcr.io/kpt-fn/fix:unstable --include-meta-resources ``` diff --git a/functions/go/search-replace/README.md b/functions/go/search-replace/README.md index 8abe97b9e..c27916365 100644 --- a/functions/go/search-replace/README.md +++ b/functions/go/search-replace/README.md @@ -148,32 +148,32 @@ a: -```sh +```shell # Matches fields with value "3": $ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-value=3 ``` -```sh +```shell # Matches fields with value prefixed by "nginx-": $ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-value-regex='ngnix-.*' ``` -```sh +```shell # Matches field with path "spec.namespaces" set to "bookstore": $ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-path='metadata.namespace' by-value='bookstore' ``` -```sh +```shell # Matches fields with name "containerPort" arbitrarily deep in "spec" that have value of 80: $ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-path='spec.**.containerPort' by-value=80 ``` -```sh +```shell # Set namespaces for all resources to "bookstore", even namespace is not set on a resource: $ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-path='metadata.namespace' put-value='bookstore' ``` -```sh +```shell # Search and Set multiple values using regex numbered capture groups $ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-value-regex='something-(.*)' put-value='my-project-id-${1}' metadata: @@ -185,7 +185,7 @@ metadata: namespace: my-project-id-bar ``` -```sh +```shell # Put the setter pattern as a line comment for matching fields. $ kpt fn run --image gcr.io/kpt-fn/search-replace:unstable -- by-value='my-project-id-foo' put-comment='kpt-set: ${project-id}-foo' metadata: diff --git a/tests/e2e.sh b/tests/e2e.sh index bc7bcea9a..133f7c3d4 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -17,8 +17,9 @@ # E2E tests for catalog functions. set -eo pipefail -#DIR="$(dirname "$0")" # Temporarily skip this test. # TODO(mengqiy): re-enable it after migrating all contrib functions. +#DIR="$(dirname "$0")" + #"$DIR"/sops.sh