mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
Add --env/-e flag
This commit is contained in:
@@ -69,6 +69,9 @@ func GetRunFnRunner(name string) *RunFnRunner {
|
|||||||
"a list of storage options read from the filesystem")
|
"a list of storage options read from the filesystem")
|
||||||
r.Command.Flags().BoolVar(
|
r.Command.Flags().BoolVar(
|
||||||
&r.LogSteps, "log-steps", false, "log steps to stderr")
|
&r.LogSteps, "log-steps", false, "log steps to stderr")
|
||||||
|
r.Command.Flags().StringArrayVarP(
|
||||||
|
&r.Env, "env", "e", []string{},
|
||||||
|
"a list of environment variables to be used by functions")
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +99,7 @@ type RunFnRunner struct {
|
|||||||
NetworkName string
|
NetworkName string
|
||||||
Mounts []string
|
Mounts []string
|
||||||
LogSteps bool
|
LogSteps bool
|
||||||
|
Env []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RunFnRunner) runE(c *cobra.Command, args []string) error {
|
func (r *RunFnRunner) runE(c *cobra.Command, args []string) error {
|
||||||
@@ -311,6 +315,7 @@ func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
|
|||||||
StorageMounts: storageMounts,
|
StorageMounts: storageMounts,
|
||||||
ResultsDir: r.ResultsDir,
|
ResultsDir: r.ResultsDir,
|
||||||
LogSteps: r.LogSteps,
|
LogSteps: r.LogSteps,
|
||||||
|
Env: r.Env,
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't consider args for the function
|
// don't consider args for the function
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ apiVersion: v1
|
|||||||
Path: "dir",
|
Path: "dir",
|
||||||
NetworkName: "bridge",
|
NetworkName: "bridge",
|
||||||
EnableStarlark: true,
|
EnableStarlark: true,
|
||||||
|
Env: []string{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -257,6 +258,7 @@ apiVersion: v1
|
|||||||
Path: "dir",
|
Path: "dir",
|
||||||
NetworkName: "bridge",
|
NetworkName: "bridge",
|
||||||
ResultsDir: "foo/",
|
ResultsDir: "foo/",
|
||||||
|
Env: []string{},
|
||||||
},
|
},
|
||||||
expected: `
|
expected: `
|
||||||
metadata:
|
metadata:
|
||||||
@@ -292,6 +294,17 @@ apiVersion: v1
|
|||||||
Path: "dir",
|
Path: "dir",
|
||||||
NetworkName: "bridge",
|
NetworkName: "bridge",
|
||||||
LogSteps: true,
|
LogSteps: true,
|
||||||
|
Env: []string{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "envs",
|
||||||
|
args: []string{"run", "dir", "--env", "FOO=BAR", "-e", "BAR"},
|
||||||
|
path: "dir",
|
||||||
|
expectedStruct: &runfn.RunFns{
|
||||||
|
Path: "dir",
|
||||||
|
NetworkName: "bridge",
|
||||||
|
Env: []string{"FOO=BAR", "BAR"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user