import "sigs.k8s.io/kustomize/api/internal/plugins"
Read docs/plugins.md first for an overview of kustomize plugins.
There are two kinds of plugins, Go plugins (shared object library) and exec plugins (independent binary). For performance and standardized testing reasons, all builtin plugins are Go plugins (not exec plugins).
Using "SecretGenerator" as an example in what follows.
The plugin config file looks like
apiVersion: builtin kind: SecretGenerator metadata: name: whatever otherField1: whatever otherField2: whatever ...
The apiVersion must be 'builtin'.
The kind is the CamelCase name of the plugin.
The source for a builtin plugin must be at:
repo=$GOPATH/src/sigs.k8s.io/kustomize ${repo}/plugin/builtin/LOWERCASE(${kind})/${kind}
k8s wants 'kind' values to follow CamelCase, while Go style doesn't like but does allow such names.
The lowercased value of kind is used as the name of the directory holding the plugin, its test, and any optional associated files (possibly a go.mod file).
The `pluginator` program is a code generator that converts kustomize generator (G) and/or transformer (T) Go plugins to statically linkable code.
It arises from following requirements:
The extension requirement led to building a framework that accommodates writing a G or T as either
The dogfooding (and an implicit performance requirement) requires a 'builtin' G or T to be written as a Go plugin.
The distribution ('go get') requirement demands conversion of Go plugins to statically linked code, hence this program.
TO GENERATE CODE
repo=$GOPATH/src/sigs.k8s.io/kustomize cd $repo/plugin/builtin go generate ./...
This creates
$repo/api/plugins/builtins/SecretGenerator.go
etc.
Generated plugins are used in kustomize via
package whatever import sigs.k8s.io/kustomize/api/plugins/builtins ... g := builtin.NewSecretGenerator() g.Config(h, k) resources, err := g.Generate() err = g.Transform(resources) // Eventually emit resources.
Name | Synopsis |
---|---|
.. |