From 6a4150d199cf078a7fc369f372fcc8d30a5f46a6 Mon Sep 17 00:00:00 2001 From: Yujun Zhang Date: Thu, 5 Sep 2019 13:56:37 +0800 Subject: [PATCH] Amend go-getter plugin document according to comments --- examples/goGetterGeneratorPlugin.md | 42 +++++++++++-------- .../someteam.example.com/v1/gogetter/GoGetter | 2 +- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/examples/goGetterGeneratorPlugin.md b/examples/goGetterGeneratorPlugin.md index e957d5a5a..16a347f17 100644 --- a/examples/goGetterGeneratorPlugin.md +++ b/examples/goGetterGeneratorPlugin.md @@ -11,9 +11,10 @@ To extend the supported format, Kustomize has a [plugin] system that allows one ## Make a place to work - + ```sh DEMO_HOME=$(mktemp -d) +mkdir -p $DEMO_HOME/base ``` ## Use a remote kustomize layer @@ -22,18 +23,18 @@ Define a kustomization representing your _local_ variant (aka environment). This could involve any number of kustomizations (see other examples), but in this case just add the name prefix `my-` to all resources: - + ```sh -cat <<'EOF' >$DEMO_HOME/my/kustomization.yaml +cat <<'EOF' >$DEMO_HOME/kustomization.yaml namePrefix: my- resources: -- ../base +- base/ EOF ``` It refer a remote base defined as below: - + ```sh cat <<'EOF' >$DEMO_HOME/base/kustomization.yaml generators: @@ -47,7 +48,7 @@ This file lets one specify the source URL, and other things like sub path in the Create the config file `goGetter.yaml`, specifying the arbitrarily chosen name _example_: - + ```sh cat <<'EOF' >$DEMO_HOME/base/goGetter.yaml apiVersion: someteam.example.com/v1 @@ -62,7 +63,7 @@ Because this particular YAML file is listed in the `generators:` stanza of a kus Download the plugin to your `DEMO_HOME` and make it executable: - + ```sh plugin=plugin/someteam.example.com/v1/gogetter/GoGetter curl -s --create-dirs -o \ @@ -75,7 +76,7 @@ chmod a+x $DEMO_HOME/kustomize/$plugin Define a helper function to run kustomize with the correct environment and flags for plugins: - + ```sh function kustomizeIt { XDG_CONFIG_HOME=$DEMO_HOME \ @@ -87,22 +88,27 @@ function kustomizeIt { Finally, build the local variant. Notice that all resource names now have the `my-` prefix: - + ```sh clear -kustomizeIt my +kustomizeIt ``` Compare local variant to remote base: - + ```sh -diff <(kustomizeIt my) <(kustomizeIt base) | more +diff <(kustomizeIt) <(kustomizeIt base) | more + +... +< name: my-remote-cm +--- +> name: remote-cm ``` -To see the unmodified but extracted sources, run kustomize on the base. Every invocation here is re-downloading and re-build the package. +To see the unmodified but extracted sources, run kustomize on the base. Every invocation here is re-downloading and re-building the package. - + ```sh kustomizeIt base ``` @@ -111,16 +117,16 @@ kustomizeIt base Sometimes the remote sources does not include `kustomization.yaml`. To use that in the plugin, set command to override the default build. - + ```sh echo "command: cat resources.yaml" >>$DEMO_HOME/base/goGetter.yaml ``` Finally, built it - + ```sh -kustomizeIt my +kustomizeIt ``` -and observe the transformation from remote kustomization.yaml is not included. +and observe the output includes raw `resources.yaml` instead of building result of remote `kustomization.yaml`. diff --git a/plugin/someteam.example.com/v1/gogetter/GoGetter b/plugin/someteam.example.com/v1/gogetter/GoGetter index 604c2dad2..efdd566d3 100755 --- a/plugin/someteam.example.com/v1/gogetter/GoGetter +++ b/plugin/someteam.example.com/v1/gogetter/GoGetter @@ -21,7 +21,7 @@ # # TODO: cache downloads -set -ex +set -e # YAML parsing function borrowed from ChartInflator function parseYaml {