diff --git a/api/krusty/generatorplugin_test.go b/api/krusty/generatorplugin_test.go new file mode 100644 index 00000000000..68d5b3ec612 --- /dev/null +++ b/api/krusty/generatorplugin_test.go @@ -0,0 +1,132 @@ +package krusty_test + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest" + "sigs.k8s.io/kustomize/kyaml/filesys" +) + +func TestGeneratorHashSuffixWithMergeBehavior(t *testing.T) { + fSys := filesys.MakeFsOnDisk() + generatorFilename := "generateWithHashRequest.sh" + + th := kusttest_test.MakeHarnessWithFs(t, fSys) + o := th.MakeOptionsPluginsEnabled() + o.PluginConfig.FnpLoadingOptions.EnableExec = true + + tmpDir, err := filesys.NewTmpConfirmedDir() + assert.NoError(t, err) + th.WriteK(tmpDir.String(), ` +resources: +- configmap.yaml +generators: +- |- + kind: Executable + metadata: + name: demo + annotations: + config.kubernetes.io/function: | + exec: + path: ./`+generatorFilename+` +`) + + th.WriteF(filepath.Join(tmpDir.String(), "configmap.yaml"), ` +apiVersion: v1 +kind: ConfigMap +metadata: + name: cmap +data: + a: b +`) + th.WriteF(filepath.Join(tmpDir.String(), generatorFilename), `#!/bin/sh + +cat <