add secret and configmap generator plugins

This commit is contained in:
Seth Pollack
2019-03-15 14:28:18 -04:00
parent e7be999bc9
commit 18f6328284
12 changed files with 325 additions and 9 deletions

View File

@@ -240,3 +240,31 @@ metadata:
name: p2-com2-c4b8md75k9
`)
}
func TestGeneratorPlugins(t *testing.T) {
th := NewKustTestHarness(t, "/app")
th.writeK("/app", `
secretGenerator:
- name: bob
kvSources:
- pluginType: testonly
name: testonly
args:
- FRUIT
- VEGETABLE
`)
m, err := th.makeKustTarget().MakeCustomizedResMap()
if err != nil {
t.Fatalf("Err: %v", err)
}
th.assertActualEqualsExpected(m, `
apiVersion: v1
data:
k_FRUIT: dl9GUlVJVA==
k_VEGETABLE: dl9WRUdFVEFCTEU=
kind: Secret
metadata:
name: bob-cb9mhbh9gg
type: Opaque
`)
}

View File

@@ -189,6 +189,9 @@ type GeneratorArgs struct {
// DataSources for the generator.
DataSources `json:",inline,omitempty" yaml:",inline,omitempty"`
// KVSources for the generator.
KVSources []KVSource `json:",inline,omitempty" yaml:",inline,omitempty"`
}
// ConfigMapArgs contains the metadata of how to generate a configmap.
@@ -248,3 +251,10 @@ type GeneratorOptions struct {
// resource contents.
DisableNameSuffixHash bool `json:"disableNameSuffixHash,omitempty" yaml:"disableNameSuffixHash,omitempty"`
}
// KVSource represents a KV plugin backend.
type KVSource struct {
PluginType string `json:"pluginType,omitempty" yaml:"pluginType,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Args []string `json:"args,omitempty" yaml:"args,omitempty"`
}