From 5ee6380b1c7d84d13118d08e8b923f7442bc39b9 Mon Sep 17 00:00:00 2001 From: Prachi Pendse Date: Fri, 3 Jan 2020 10:52:56 +0530 Subject: [PATCH] Docs and examples use config.k8s.io/function annotation - Update function docs to recommend new annotation - Update examples to use config.k8s.io/function annotation --- cmd/config/docs/api-conventions/config-fn.md | 10 +++++----- cmd/config/docs/commands/run-fns.md | 14 +++++++------- cmd/config/internal/generateddocs/api/docs.go | 10 +++++----- cmd/config/internal/generateddocs/commands/docs.go | 14 +++++++------- .../examples/injection-tshirt-sizes/README.md | 2 +- .../local-resource/example-use.yaml | 7 ++++--- functions/examples/template-go-nginx/README.md | 2 +- .../local-resource/example-use.yaml | 7 ++++--- .../template-heredoc-cockroachdb/README.md | 2 +- .../local-resource/example-use.yaml | 7 ++++--- functions/examples/validator-kubeval/README.md | 2 +- .../local-resource/example-use.yaml | 7 ++++--- .../examples/validator-resource-requests/README.md | 2 +- .../local-resource/example-use.yaml | 7 ++++--- 14 files changed, 49 insertions(+), 44 deletions(-) diff --git a/cmd/config/docs/api-conventions/config-fn.md b/cmd/config/docs/api-conventions/config-fn.md index ca159ebae..8720812ab 100644 --- a/cmd/config/docs/api-conventions/config-fn.md +++ b/cmd/config/docs/api-conventions/config-fn.md @@ -222,15 +222,15 @@ Following is an example of running the `kustomize config run` using the precedin metadata: name: my-instance annotations: + config.k8s.io/function: | + container: + image: gcr.io/example-functions/nginx-template:v1.0.0 config.kubernetes.io/local-config: "true" - configFn: - container: - image: gcr.io/example-functions/nginx-template:v1.0.0 spec: replicas: 5 - - `configFn.container.image`: the image to use for this API - - `annotations[config.kubernetes.io/local-config]`: mark this as not a Resource that should + - `annotations.[config.k8s.io/function]`: the image to use for this API + - `annotations.[config.kubernetes.io/local-config]`: mark this as not a Resource that should be applied #### `kustomize config run dir/` (Output) diff --git a/cmd/config/docs/commands/run-fns.md b/cmd/config/docs/commands/run-fns.md index c4b0491c2..48e934d8f 100644 --- a/cmd/config/docs/commands/run-fns.md +++ b/cmd/config/docs/commands/run-fns.md @@ -22,8 +22,8 @@ order they appear in the file). #### Config Functions: - Config functions are specified as Kubernetes types containing a metadata.configFn.container.image - field. This field tells run how to invoke the container. + Config functions are specified as Kubernetes types containing a metadata.annotations.[config.k8s.io/function] + field specifying an image for the container to run. This image tells run how to invoke the container. Example config function: @@ -31,17 +31,17 @@ order they appear in the file). apiVersion: fn.example.com/v1beta1 kind: ExampleFunctionKind metadata: - configFn: - container: - # function is invoked as a container running this image - image: gcr.io/example/examplefunction:v1.0.1 annotations: + config.k8s.io/function: | + container: + # function is invoked as a container running this image + image: gcr.io/example/examplefunction:v1.0.1 config.kubernetes.io/local-config: "true" # tools should ignore this spec: configField: configValue In the preceding example, 'kustomize config run example/' would identify the function by - the metadata.configFn field. It would then write all Resources in the directory to + the metadata.annotations.[config.k8s.io/function] field. It would then write all Resources in the directory to a container stdin (running the gcr.io/example/examplefunction:v1.0.1 image). It would then write the container stdout back to example/, replacing the directory file contents. diff --git a/cmd/config/internal/generateddocs/api/docs.go b/cmd/config/internal/generateddocs/api/docs.go index 39907c1b6..ea7892303 100644 --- a/cmd/config/internal/generateddocs/api/docs.go +++ b/cmd/config/internal/generateddocs/api/docs.go @@ -228,15 +228,15 @@ Following is an example of running the ` + "`" + `kustomize config run` + "`" + metadata: name: my-instance annotations: + config.k8s.io/function: | + container: + image: gcr.io/example-functions/nginx-template:v1.0.0 config.kubernetes.io/local-config: "true" - configFn: - container: - image: gcr.io/example-functions/nginx-template:v1.0.0 spec: replicas: 5 - - ` + "`" + `configFn.container.image` + "`" + `: the image to use for this API - - ` + "`" + `annotations[config.kubernetes.io/local-config]` + "`" + `: mark this as not a Resource that should + - ` + "`" + `annotations.[config.k8s.io/function]` + "`" + `: the image to use for this API + - ` + "`" + `annotations.[config.kubernetes.io/local-config]` + "`" + `: mark this as not a Resource that should be applied #### ` + "`" + `kustomize config run dir/` + "`" + ` (Output) diff --git a/cmd/config/internal/generateddocs/commands/docs.go b/cmd/config/internal/generateddocs/commands/docs.go index c4d11e567..815f3520d 100644 --- a/cmd/config/internal/generateddocs/commands/docs.go +++ b/cmd/config/internal/generateddocs/commands/docs.go @@ -201,8 +201,8 @@ order they appear in the file). #### Config Functions: - Config functions are specified as Kubernetes types containing a metadata.configFn.container.image - field. This field tells run how to invoke the container. + Config functions are specified as Kubernetes types containing a metadata.annotations.[config.k8s.io/function] + field specifying an image for the container to run. This image tells run how to invoke the container. Example config function: @@ -210,17 +210,17 @@ order they appear in the file). apiVersion: fn.example.com/v1beta1 kind: ExampleFunctionKind metadata: - configFn: - container: - # function is invoked as a container running this image - image: gcr.io/example/examplefunction:v1.0.1 annotations: + config.k8s.io/function: | + container: + # function is invoked as a container running this image + image: gcr.io/example/examplefunction:v1.0.1 config.kubernetes.io/local-config: "true" # tools should ignore this spec: configField: configValue In the preceding example, 'kustomize config run example/' would identify the function by - the metadata.configFn field. It would then write all Resources in the directory to + the metadata.annotations.[config.k8s.io/function] field. It would then write all Resources in the directory to a container stdin (running the gcr.io/example/examplefunction:v1.0.1 image). It would then write the container stdout back to example/, replacing the directory file contents. diff --git a/functions/examples/injection-tshirt-sizes/README.md b/functions/examples/injection-tshirt-sizes/README.md index 97625fab1..204ea11d8 100644 --- a/functions/examples/injection-tshirt-sizes/README.md +++ b/functions/examples/injection-tshirt-sizes/README.md @@ -15,7 +15,7 @@ Resource configuration, and looks for invalid configuration. ## Function invocation The function is invoked by authoring a [local Resource](local-resource) -with `metadata.configFn` and running: +with `metadata.annotations.[config.k8s.io/function]` and running: kustomize config run local-resource/ diff --git a/functions/examples/injection-tshirt-sizes/local-resource/example-use.yaml b/functions/examples/injection-tshirt-sizes/local-resource/example-use.yaml index 19235b192..71f3d8878 100644 --- a/functions/examples/injection-tshirt-sizes/local-resource/example-use.yaml +++ b/functions/examples/injection-tshirt-sizes/local-resource/example-use.yaml @@ -4,9 +4,10 @@ apiVersion: examples.config.kubernetes.io/v1beta1 kind: Validator metadata: - configFn: - container: - image: gcr.io/kustomize-functions/example-tshirt:v0.1.0 + annotations: + config.k8s.io/function: | + container: + image: gcr.io/kustomize-functions/example-tshirt:v0.1.0 --- apiVersion: apps/v1 kind: Deployment diff --git a/functions/examples/template-go-nginx/README.md b/functions/examples/template-go-nginx/README.md index 94e529328..f90913b28 100644 --- a/functions/examples/template-go-nginx/README.md +++ b/functions/examples/template-go-nginx/README.md @@ -25,7 +25,7 @@ function input, and writing the function output. ## Function invocation The function is invoked by authoring a [local Resource](local-resource) -with `metadata.configFn` and running: +with `metadata.annotations.[config.k8s.io/function]` and running: kustomize config run local-resource/ diff --git a/functions/examples/template-go-nginx/local-resource/example-use.yaml b/functions/examples/template-go-nginx/local-resource/example-use.yaml index 7e3153903..f0de94576 100644 --- a/functions/examples/template-go-nginx/local-resource/example-use.yaml +++ b/functions/examples/template-go-nginx/local-resource/example-use.yaml @@ -5,8 +5,9 @@ apiVersion: examples.config.kubernetes.io/v1beta1 # call `kustomize config run` kind: Nginx metadata: name: demo - configFn: - container: - image: gcr.io/kustomize-functions/example-nginx:v0.1.0 + annotations: + config.k8s.io/function: | + container: + image: gcr.io/kustomize-functions/example-nginx:v0.1.0 spec: replicas: 4 diff --git a/functions/examples/template-heredoc-cockroachdb/README.md b/functions/examples/template-heredoc-cockroachdb/README.md index da390b012..68bb23bf3 100644 --- a/functions/examples/template-heredoc-cockroachdb/README.md +++ b/functions/examples/template-heredoc-cockroachdb/README.md @@ -20,7 +20,7 @@ heavy lifting of implementing the function interface. ## Function invocation The function is invoked by authoring a [local Resource](local-resource) -with `metadata.configFn` and running: +with `metadata.annotations.[config.k8s.io/function]` and running: kustomize config run local-resource/ diff --git a/functions/examples/template-heredoc-cockroachdb/local-resource/example-use.yaml b/functions/examples/template-heredoc-cockroachdb/local-resource/example-use.yaml index a04b822bc..fa598b488 100644 --- a/functions/examples/template-heredoc-cockroachdb/local-resource/example-use.yaml +++ b/functions/examples/template-heredoc-cockroachdb/local-resource/example-use.yaml @@ -6,8 +6,9 @@ apiVersion: examples.config.kubernetes.io/v1beta1 kind: CockroachDB metadata: name: demo - configFn: - container: - image: gcr.io/kustomize-functions/example-cockroachdb:v0.1.0 + annotations: + config.k8s.io/function: | + container: + image: gcr.io/kustomize-functions/example-cockroachdb:v0.1.0 spec: replicas: 3 diff --git a/functions/examples/validator-kubeval/README.md b/functions/examples/validator-kubeval/README.md index aabcb87f3..ffbc98608 100644 --- a/functions/examples/validator-kubeval/README.md +++ b/functions/examples/validator-kubeval/README.md @@ -18,7 +18,7 @@ the `API` struct definition in [main.go](image/main.go) for documentation. ## Function invocation The function is invoked by authoring a [local Resource](local-resource) -with `metadata.configFn` and running: +with `metadata.annotations.[config.k8s.io/function]` and running: kustomize config run local-resource/ diff --git a/functions/examples/validator-kubeval/local-resource/example-use.yaml b/functions/examples/validator-kubeval/local-resource/example-use.yaml index 3ec77bae7..96fdb80f7 100644 --- a/functions/examples/validator-kubeval/local-resource/example-use.yaml +++ b/functions/examples/validator-kubeval/local-resource/example-use.yaml @@ -4,9 +4,10 @@ apiVersion: examples.config.kubernetes.io/v1beta1 kind: Kubeval metadata: - configFn: - container: - image: gcr.io/kustomize-functions/example-validator-kubeval:v0.1.0 + annotations: + config.k8s.io/function: | + container: + image: gcr.io/kustomize-functions/example-validator-kubeval:v0.1.0 spec: strict: true ignoreMissingSchemas: true diff --git a/functions/examples/validator-resource-requests/README.md b/functions/examples/validator-resource-requests/README.md index 7f30f21a6..9689a0b69 100644 --- a/functions/examples/validator-resource-requests/README.md +++ b/functions/examples/validator-resource-requests/README.md @@ -15,7 +15,7 @@ Resource configuration, and looks for invalid configuration. ## Function invocation The function is invoked by authoring a [local Resource](local-resource) -with `metadata.configFn` and running: +with `metadata.annotations.[config.k8s.io/function]` and running: kustomize config run local-resource/ diff --git a/functions/examples/validator-resource-requests/local-resource/example-use.yaml b/functions/examples/validator-resource-requests/local-resource/example-use.yaml index c90e66fe9..39f537f79 100644 --- a/functions/examples/validator-resource-requests/local-resource/example-use.yaml +++ b/functions/examples/validator-resource-requests/local-resource/example-use.yaml @@ -4,9 +4,10 @@ apiVersion: examples.config.kubernetes.io/v1beta1 kind: Validator metadata: - configFn: - container: - image: gcr.io/kustomize-functions/example-validator:v0.1.0 + annotations: + config.k8s.io/function: | + container: + image: gcr.io/kustomize-functions/example-validator:v0.1.0 --- apiVersion: apps/v1 # this should fail validation kind: Deployment