add goplugin for exec generators and transformers

This commit is contained in:
Jingfang Liu
2019-04-09 11:19:33 -07:00
parent ee68a9c450
commit ba43ecbcb7
7 changed files with 180 additions and 10 deletions

View File

@@ -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