mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
exec function working dir is the kustomization that referenced it (#4125)
* exec function working dir is the kustomization that referenced it * suggested changes * more code review * use a field instead of an annotation * more code review
This commit is contained in:
@@ -11,13 +11,14 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"sigs.k8s.io/kustomize/kyaml/runfn"
|
||||
)
|
||||
|
||||
// TestRunFnCommand_preRunE verifies that preRunE correctly parses the commandline
|
||||
// flags and arguments into the RunFns structure to be executed.
|
||||
func TestRunFnCommand_preRunE(t *testing.T) {
|
||||
wd, err := os.Getwd()
|
||||
assert.NoError(t, err)
|
||||
tests := []struct {
|
||||
name string
|
||||
args []string
|
||||
@@ -201,6 +202,7 @@ apiVersion: v1
|
||||
Path: "dir",
|
||||
EnableStarlark: true,
|
||||
Env: []string{},
|
||||
WorkingDir: wd,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -254,6 +256,7 @@ apiVersion: v1
|
||||
Path: "dir",
|
||||
ResultsDir: "foo/",
|
||||
Env: []string{},
|
||||
WorkingDir: wd,
|
||||
},
|
||||
expected: `
|
||||
metadata:
|
||||
@@ -286,9 +289,10 @@ apiVersion: v1
|
||||
args: []string{"run", "dir", "--log-steps"},
|
||||
path: "dir",
|
||||
expectedStruct: &runfn.RunFns{
|
||||
Path: "dir",
|
||||
LogSteps: true,
|
||||
Env: []string{},
|
||||
Path: "dir",
|
||||
LogSteps: true,
|
||||
Env: []string{},
|
||||
WorkingDir: wd,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -296,8 +300,9 @@ apiVersion: v1
|
||||
args: []string{"run", "dir", "--env", "FOO=BAR", "-e", "BAR"},
|
||||
path: "dir",
|
||||
expectedStruct: &runfn.RunFns{
|
||||
Path: "dir",
|
||||
Env: []string{"FOO=BAR", "BAR"},
|
||||
Path: "dir",
|
||||
Env: []string{"FOO=BAR", "BAR"},
|
||||
WorkingDir: wd,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -308,6 +313,7 @@ apiVersion: v1
|
||||
Path: "dir",
|
||||
AsCurrentUser: true,
|
||||
Env: []string{},
|
||||
WorkingDir: wd,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user