mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-29 17:41:13 +00:00
add goplugin for exec generators and transformers
This commit is contained in:
@@ -127,3 +127,37 @@ metadata:
|
||||
type: Opaque
|
||||
`)
|
||||
}
|
||||
|
||||
func TestConfigMapGenerator(t *testing.T) {
|
||||
tc := NewTestEnvController(t).Set()
|
||||
//defer tc.Reset()
|
||||
|
||||
tc.BuildExecPlugin(
|
||||
"someteam.example.com", "v1", "ConfigMapGenerator")
|
||||
|
||||
th := NewKustTestHarnessWithPluginConfig(
|
||||
t, "/app", plugin.ActivePluginConfig())
|
||||
th.writeK("/app", `
|
||||
generators:
|
||||
- configmapGenerator.yaml
|
||||
`)
|
||||
th.writeF("/app/configmapGenerator.yaml", `
|
||||
apiVersion: someteam.example.com/v1
|
||||
kind: ConfigMapGenerator
|
||||
metadata:
|
||||
name: some-random-name
|
||||
`)
|
||||
m, err := th.makeKustTarget().MakeCustomizedResMap()
|
||||
if err != nil {
|
||||
t.Fatalf("Err: %v", err)
|
||||
}
|
||||
th.assertActualEqualsExpected(m, `
|
||||
apiVersion: v1
|
||||
data:
|
||||
password: secret
|
||||
username: admin
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: example-configmap-test
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package target_test
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sigs.k8s.io/kustomize/k8sdeps/kv/plugin"
|
||||
"testing"
|
||||
@@ -57,6 +58,28 @@ func (x *TestEnvController) BuildGoPlugin(g, v, k string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (x *TestEnvController) BuildExecPlugin(name ...string) {
|
||||
obj := filepath.Join(
|
||||
append([]string{x.workDir, pgmconfig.ProgramName, plugin.PluginRoot}, name...)...)
|
||||
|
||||
srcRoot, err := plugins.DefaultSrcRoot()
|
||||
if err != nil {
|
||||
x.t.Error(err)
|
||||
}
|
||||
|
||||
src := filepath.Join(
|
||||
append([]string{srcRoot}, name...)...)
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(obj), 0755); err != nil {
|
||||
x.t.Errorf("error making directory: %s", filepath.Dir(obj))
|
||||
}
|
||||
cmd := exec.Command("cp", src, obj)
|
||||
cmd.Env = os.Environ()
|
||||
if err := cmd.Run(); err != nil {
|
||||
x.t.Errorf("error copying %s: %v", src, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *TestEnvController) makeCompiler() *plugins.Compiler {
|
||||
// The plugin loader wants to find object code under
|
||||
// $XDG_CONFIG_HOME/kustomize/plugins
|
||||
|
||||
Reference in New Issue
Block a user