Debian Codegraph @

plugin/README.md

raw
1 # kustomize plugins
2
3 This directory holds [kustomize plugins][extending kustomize],
4 each in its own sub-directory.
5
6 ### Directories
7
8 * `builtin`
9
10 These are plugins written as [Go plugins].
11
12 They are converted to statically linked code in the
13 kustomize binary by a code generator ([pluginator]) at
14 kustomize build time.
15
16 They are maintained as part of kustomize.
17
18 * `someteam.example.com/v1`
19
20 Example plugins, maintained
21 and tested by the kustomize maintainers,
22 but not built-in to kustomize.
23
24 Some of these might get promoted to `builtin` someday,
25 as happened with the [Helm Chart Inflator].
26
27 * `untested/v1`
28
29 Untested, unmaintained plugins.
30
31 These might be former examples that have been abandoned and
32 may soon be deleted, or they might be WIP plugins that will
33 someday become examples or builtins.
34
35 #### Testing
36
37 Regardless of the [style](#plugin-styles) used to write a plugin,
38 it should be accompanied by a Go unit test, written using the framework
39 maintained by the kustomize maintainers for just that purpose.
40
41 To see how this works, run any plugin test, e.g.
42 this plugin written in bash:
43 ```
44 pushd plugin/someteam.example.com/v1/bashedconfigmap
45 go test -v .
46 popd
47 ```
48
49 For plugins with many tests, it's possible to target just one test:
50 ```
51 pushd plugin/builtin/patchstrategicmergetransformer
52 go test -v -run TestBadPatchStrategicMergeTransformer PatchStrategicMergeTransformer_test.go
53 popd
54 ```
55
56 ### Plugin styles
57
58 For more discussion, see [extending kustomize].
59
60 * a bare executable
61
62 This can be anything, e.g. a shell script, a shell
63 script that runs java in a JVM, or python in a python
64 VM, etc. They accept a YAML stream of resources on
65 stdin, and emit a YAML stream on stdout. They accept
66 configuration data in a file specified as the first
67 argument on their command line.
68
69 If the executable is written in Go, it can take advantage
70 of the same libraries as the kustomize builtin plugins.
71
72 * a [KRM function]
73
74 These are containerized executables, that are pickier
75 about their input. Rather than accepting a YAML stream
76 of k8s resources, they want one `ResourceList` object
77 (with the resources in that list).
78
79 * a [Go plugin]
80
81 These are built as shared object libraries. Like
82 a Go program, they're written in an unimportable
83 `main` package with its own `go.mod` file.
84 Go plugins cannot be reliably distributed (see docs),
85 and are meant only as a structured way to write a
86 builtin plugin intended for distribution with kustomize.
87
88 [pluginator]: ../cmd/pluginator
89 [Helm Chart Inflator]: ./builtin/helmchartinflationgenerator
90 [KRM function]: https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/api-conventions/functions-spec.md
91 [Go plugin]: https://golang.org/pkg/plugin
92 [Go plugins]: https://golang.org/pkg/plugin
93 [extending kustomize]: https://kubectl.docs.kubernetes.io/guides/extending_kustomize/
94