From 0d8d9e2f2bf6b9282ea86998e5c22ba3f7d0f868 Mon Sep 17 00:00:00 2001 From: Richard Marshall Date: Wed, 10 Jul 2019 17:16:05 -0700 Subject: [PATCH] Move plugin EnvForTest manager into new package Move the EnvForTest manager into an independent package that is not imported by any non-test code. Previously this code was directly embedded in the plugins package resulting in testing flags being exposed in the main kustomize binary. --- pkg/plugins/{ => test}/envfortest.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) rename pkg/plugins/{ => test}/envfortest.go (91%) diff --git a/pkg/plugins/envfortest.go b/pkg/plugins/test/envfortest.go similarity index 91% rename from pkg/plugins/envfortest.go rename to pkg/plugins/test/envfortest.go index 928d32646..c92f996ff 100644 --- a/pkg/plugins/envfortest.go +++ b/pkg/plugins/test/envfortest.go @@ -1,7 +1,7 @@ // Copyright 2019 The Kubernetes Authors. // SPDX-License-Identifier: Apache-2.0 -package plugins +package test import ( "io/ioutil" @@ -12,13 +12,14 @@ import ( "testing" "sigs.k8s.io/kustomize/v3/pkg/pgmconfig" + "sigs.k8s.io/kustomize/v3/pkg/plugins" ) // EnvForTest manages the plugin test environment. // It sets/resets XDG_CONFIG_HOME, makes/removes a temp objRoot. type EnvForTest struct { t *testing.T - compiler *Compiler + compiler *plugins.Compiler workDir string oldXdg string wasSet bool @@ -61,7 +62,7 @@ func (x *EnvForTest) BuildExecPlugin(g, v, k string) { } } -func (x *EnvForTest) makeCompiler() *Compiler { +func (x *EnvForTest) makeCompiler() *plugins.Compiler { // The plugin loader wants to find object code under // $XDG_CONFIG_HOME/kustomize/plugins // and the compiler writes object code to @@ -73,11 +74,11 @@ func (x *EnvForTest) makeCompiler() *Compiler { if err != nil { x.t.Error(err) } - srcRoot, err := DefaultSrcRoot() + srcRoot, err := plugins.DefaultSrcRoot() if err != nil { x.t.Error(err) } - return NewCompiler(srcRoot, objRoot) + return plugins.NewCompiler(srcRoot, objRoot) } func (x *EnvForTest) createWorkDir() {