mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Hack for local testing of isolated plugins.
This commit is contained in:
@@ -31,16 +31,16 @@ type KustTestHarness struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewKustTestHarness(t *testing.T, path string) *KustTestHarness {
|
func NewKustTestHarness(t *testing.T, path string) *KustTestHarness {
|
||||||
return NewKustTestHarnessWithPluginConfig(
|
return newHarness(
|
||||||
t, path, plugins.DefaultPluginConfig())
|
t, path, plugins.DefaultPluginConfig())
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewKustTestPluginHarness(t *testing.T, path string) *KustTestHarness {
|
func NewKustTestPluginHarness(t *testing.T, path string) *KustTestHarness {
|
||||||
return NewKustTestHarnessWithPluginConfig(
|
return newHarness(
|
||||||
t, path, plugins.ActivePluginConfig())
|
t, path, plugins.ActivePluginConfig())
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewKustTestHarnessWithPluginConfig(
|
func newHarness(
|
||||||
t *testing.T, path string,
|
t *testing.T, path string,
|
||||||
pc *types.PluginConfig) *KustTestHarness {
|
pc *types.PluginConfig) *KustTestHarness {
|
||||||
return NewKustTestHarnessFull(t, path, loader.RestrictionRootOnly, pc)
|
return NewKustTestHarnessFull(t, path, loader.RestrictionRootOnly, pc)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ type Compiler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DefaultSrcRoot guesses where the user
|
// DefaultSrcRoot guesses where the user
|
||||||
// has her ${g}/${v}/${k}.go files.
|
// has her ${g}/${v}/$lower(${k})/${k}.go files.
|
||||||
func DefaultSrcRoot() (string, error) {
|
func DefaultSrcRoot() (string, error) {
|
||||||
var nope []string
|
var nope []string
|
||||||
var root string
|
var root string
|
||||||
@@ -109,8 +109,14 @@ func (b *Compiler) Compile(g, v, k string) error {
|
|||||||
}
|
}
|
||||||
srcFile := filepath.Join(b.srcRoot, g, v, lowK, k) + ".go"
|
srcFile := filepath.Join(b.srcRoot, g, v, lowK, k) + ".go"
|
||||||
if !FileExists(srcFile) {
|
if !FileExists(srcFile) {
|
||||||
return fmt.Errorf(
|
// Handy for tests of lone plugins.
|
||||||
"cannot find source %s", srcFile)
|
s := k + ".go"
|
||||||
|
if !FileExists(s) {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"cannot find source at '%s' or '%s'", srcFile, s)
|
||||||
|
|
||||||
|
}
|
||||||
|
srcFile = s
|
||||||
}
|
}
|
||||||
commands := []string{
|
commands := []string{
|
||||||
"build",
|
"build",
|
||||||
|
|||||||
Reference in New Issue
Block a user