Make plugin dir match Go conventions.

This commit is contained in:
jregan
2019-04-23 23:16:23 -07:00
parent 0ac48f60a5
commit cfb0c5efad
16 changed files with 29 additions and 12 deletions

View File

@@ -210,7 +210,7 @@ Plugins that generate KV pairs for kustomize
must be installed at must be installed at
> ``` > ```
> $XDG_CONFIG_HOME/kustomize/plugins/kvSource > $XDG_CONFIG_HOME/kustomize/plugin/kvSource
> ``` > ```
`XDG_CONFIG_HOME` is an environment variable `XDG_CONFIG_HOME` is an environment variable
@@ -227,7 +227,7 @@ Compile and install the plugin:
<!-- @compilePlugin @test --> <!-- @compilePlugin @test -->
``` ```
kvSources=$DEMO_HOME/kustomize/plugins/kvSources kvSources=$DEMO_HOME/kustomize/plugin/kvSources
mkdir -p $kvSources mkdir -p $kvSources
go build -buildmode plugin \ go build -buildmode plugin \
-o $kvSources/kvMaker.so \ -o $kvSources/kvMaker.so \

View File

@@ -33,7 +33,7 @@ type Registry struct {
const ( const (
PluginSymbol = "KustomizePlugin" PluginSymbol = "KustomizePlugin"
PluginRoot = "plugins" PluginRoot = "plugin"
pluginTypeGo = types.PluginType("go") pluginTypeGo = types.PluginType("go")
pluginTypeBuiltIn = types.PluginType("builtin") pluginTypeBuiltIn = types.PluginType("builtin")
) )

View File

@@ -36,6 +36,7 @@ func TestCompiler(t *testing.T) {
if configRoot != c.ObjRoot() { if configRoot != c.ObjRoot() {
t.Errorf("unexpected objRoot %s", c.ObjRoot()) t.Errorf("unexpected objRoot %s", c.ObjRoot())
} }
expectObj := filepath.Join( expectObj := filepath.Join(
c.ObjRoot(), c.ObjRoot(),
"someteam.example.com", "v1", "DatePrefixer.so") "someteam.example.com", "v1", "DatePrefixer.so")
@@ -49,6 +50,21 @@ func TestCompiler(t *testing.T) {
if !RecentFileExists(expectObj) { if !RecentFileExists(expectObj) {
t.Errorf("didn't find expected obj file %s", expectObj) t.Errorf("didn't find expected obj file %s", expectObj)
} }
expectObj = filepath.Join(
c.ObjRoot(),
"builtin", "", "SecretGenerator.so")
if FileExists(expectObj) {
t.Errorf("obj file should not exist yet: %s", expectObj)
}
err = c.Compile("builtin", "", "SecretGenerator")
if err != nil {
t.Error(err)
}
if !RecentFileExists(expectObj) {
t.Errorf("didn't find expected obj file %s", expectObj)
}
err = os.RemoveAll(c.ObjRoot()) err = os.RemoveAll(c.ObjRoot())
if err != nil { if err != nil {
t.Errorf( t.Errorf(

View File

@@ -53,7 +53,7 @@ s/$BAR/bar/g
p.Config(ldr, rf, pluginConfig) p.Config(ldr, rf, pluginConfig)
expected := "/kustomize/plugins/someteam.example.com/v1/SedTransformer" expected := "/kustomize/plugin/someteam.example.com/v1/SedTransformer"
if !strings.HasSuffix(p.name, expected) { if !strings.HasSuffix(p.name, expected) {
t.Fatalf("expected suffix '%s', got '%s'", expected, p.name) t.Fatalf("expected suffix '%s', got '%s'", expected, p.name)
} }

View File

@@ -29,7 +29,8 @@ import (
) )
const ( const (
secretGenerator = `apiVersion: kustomize.config.k8s.io/v1 secretGenerator = `
apiVersion: builtin
kind: SecretGenerator kind: SecretGenerator
metadata: metadata:
name: secretGenerator name: secretGenerator
@@ -59,7 +60,7 @@ func TestLoader(t *testing.T) {
defer tc.Reset() defer tc.Reset()
tc.BuildGoPlugin( tc.BuildGoPlugin(
"kustomize.config.k8s.io", "v1", "SecretGenerator") "builtin", "", "SecretGenerator")
tc.BuildGoPlugin( tc.BuildGoPlugin(
"someteam.example.com", "v1", "ServiceGenerator") "someteam.example.com", "v1", "ServiceGenerator")

View File

@@ -27,7 +27,7 @@ import (
// This is an example of using a helm chart as a base, // This is an example of using a helm chart as a base,
// inflating it and then customizing it with a nameprefix // inflating it and then customizing it with a nameprefix
// applied to all its resources. // applied to all its resources.
// //
// The helm chart used is downloaded from // The helm chart used is downloaded from
// https://github.com/helm/charts/tree/master/stable/minecraft // https://github.com/helm/charts/tree/master/stable/minecraft
// with each test run, so it's a bit brittle as that // with each test run, so it's a bit brittle as that
@@ -36,13 +36,13 @@ import (
// This test requires having the helm binary on the PATH. // This test requires having the helm binary on the PATH.
// //
// TODO: Download and inflate the chart, and check that // TODO: Download and inflate the chart, and check that
// in for the test. // in for the test.
func TestChartInflatorExecPlugin(t *testing.T) { func TestChartInflatorExecPlugin(t *testing.T) {
tc := plugintest_test.NewPluginTestEnv(t).Set() tc := plugintest_test.NewPluginTestEnv(t).Set()
defer tc.Reset() defer tc.Reset()
tc.BuildExecPlugin( tc.BuildExecPlugin(
"kustomize.config.k8s.io", "v1", "ChartInflatorExec") "builtin", "", "ChartInflatorExec")
th := NewKustTestHarnessWithPluginConfig( th := NewKustTestHarnessWithPluginConfig(
t, "/app", plugin.ActivePluginConfig()) t, "/app", plugin.ActivePluginConfig())
@@ -53,7 +53,7 @@ namePrefix: LOOOOOOOONG-
`) `)
th.writeF("/app/chartInflatorExec.yaml", ` th.writeF("/app/chartInflatorExec.yaml", `
apiVersion: kustomize.config.k8s.io/v1 apiVersion: builtin
kind: ChartInflatorExec kind: ChartInflatorExec
metadata: metadata:
name: notImportantHere name: notImportantHere

View File

@@ -67,7 +67,7 @@ spec:
func writeSecretGeneratorConfig(th *KustTestHarness, root string) { func writeSecretGeneratorConfig(th *KustTestHarness, root string) {
th.writeF(filepath.Join(root, "secretGenerator.yaml"), ` th.writeF(filepath.Join(root, "secretGenerator.yaml"), `
apiVersion: kustomize.config.k8s.io/v1 apiVersion: builtin
kind: SecretGenerator kind: SecretGenerator
metadata: metadata:
name: secretGenerator name: secretGenerator
@@ -102,7 +102,7 @@ func TestSecretGenerator(t *testing.T) {
defer tc.Reset() defer tc.Reset()
tc.BuildGoPlugin( tc.BuildGoPlugin(
"kustomize.config.k8s.io", "v1", "SecretGenerator") "builtin", "", "SecretGenerator")
th := NewKustTestHarnessWithPluginConfig( th := NewKustTestHarnessWithPluginConfig(
t, "/app", plugin.ActivePluginConfig()) t, "/app", plugin.ActivePluginConfig())