mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-09-15 12:18:57 +00:00
Make repo more relocatable on developer's workstation.
This commit is contained in:
@@ -30,11 +30,31 @@ type Compiler struct {
|
|||||||
objRoot string
|
objRoot string
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultSrcRoot guesses where the user
|
// DeterminePluginSrcRoot guesses where the user
|
||||||
// has her ${g}/${v}/$lower(${k})/${k}.go files.
|
// has her ${g}/${v}/$lower(${k})/${k}.go files.
|
||||||
func DefaultSrcRoot(fSys filesys.FileSystem) (string, error) {
|
func DeterminePluginSrcRoot(fSys filesys.FileSystem) (string, error) {
|
||||||
return konfig.FirstDirThatExistsElseError(
|
return konfig.FirstDirThatExistsElseError(
|
||||||
"source directory", fSys, []konfig.NotedFunc{
|
"source directory", fSys, []konfig.NotedFunc{
|
||||||
|
{
|
||||||
|
Note: "relative to unit test",
|
||||||
|
F: func() string {
|
||||||
|
return filepath.Clean(
|
||||||
|
filepath.Join(
|
||||||
|
os.Getenv("PWD"),
|
||||||
|
"..", "..", "..", "..",
|
||||||
|
konfig.RelPluginHome))
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Note: "relative to api package",
|
||||||
|
F: func() string {
|
||||||
|
return filepath.Clean(
|
||||||
|
filepath.Join(
|
||||||
|
os.Getenv("PWD"),
|
||||||
|
"..", "..", "..",
|
||||||
|
konfig.RelPluginHome))
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Note: "old style $GOPATH",
|
Note: "old style $GOPATH",
|
||||||
F: func() string {
|
F: func() string {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func TestCompiler(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to make temp dir: %v", err)
|
t.Errorf("failed to make temp dir: %v", err)
|
||||||
}
|
}
|
||||||
srcRoot, err := DefaultSrcRoot(filesys.MakeFsOnDisk())
|
srcRoot, err := DeterminePluginSrcRoot(filesys.MakeFsOnDisk())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ func (x *PluginTestEnv) makeCompiler() *compiler.Compiler {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
x.t.Error(err)
|
x.t.Error(err)
|
||||||
}
|
}
|
||||||
srcRoot, err := compiler.DefaultSrcRoot(filesys.MakeFsOnDisk())
|
srcRoot, err := compiler.DeterminePluginSrcRoot(filesys.MakeFsOnDisk())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
x.t.Error(err)
|
x.t.Error(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user