add --fn-env flag to fn run

This commit is contained in:
Donny Xia
2020-08-27 12:24:22 -07:00
parent 39cf4af638
commit 3801a29d9b
2 changed files with 29 additions and 0 deletions

View File

@@ -67,6 +67,9 @@ func GetRunFnRunner(name string) *RunFnRunner {
"a list of storage options read from the filesystem")
r.Command.Flags().StringVar(
&r.User, "fn-user", "nobody", "the username/uid used to run function in container")
r.Command.Flags().StringArrayVar(
&r.Env, "fn-env", []string{},
"a list of environment variables that will be exposed to container. Each item can be key=value pair or a key name of exported env.")
return r
}
@@ -94,6 +97,7 @@ type RunFnRunner struct {
NetworkName string
Mounts []string
User string
Env []string
}
func (r *RunFnRunner) runE(c *cobra.Command, args []string) error {
@@ -309,6 +313,7 @@ func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
StorageMounts: storageMounts,
ResultsDir: r.ResultsDir,
User: runtimeutil.ContainerUser(r.User),
Env: r.Env,
}
// don't consider args for the function