Merge pull request #3097 from Shell32-Natsu/as-current-user

add --as-current-user flag to fn run
This commit is contained in:
Kubernetes Prow Robot
2020-10-14 18:09:51 -07:00
committed by GitHub
2 changed files with 14 additions and 0 deletions

View File

@@ -70,6 +70,8 @@ func GetRunFnRunner(name string) *RunFnRunner {
r.Command.Flags().StringArrayVarP(
&r.Env, "env", "e", []string{},
"a list of environment variables to be used by functions")
r.Command.Flags().BoolVar(
&r.AsCurrentUser, "as-current-user", false, "use the uid and gid that kpt is running with to run the function in the container")
return r
}
@@ -97,6 +99,7 @@ type RunFnRunner struct {
Mounts []string
LogSteps bool
Env []string
AsCurrentUser bool
}
func (r *RunFnRunner) runE(c *cobra.Command, args []string) error {
@@ -312,6 +315,7 @@ func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
ResultsDir: r.ResultsDir,
LogSteps: r.LogSteps,
Env: r.Env,
AsCurrentUser: r.AsCurrentUser,
}
// don't consider args for the function

View File

@@ -300,6 +300,16 @@ apiVersion: v1
Env: []string{"FOO=BAR", "BAR"},
},
},
{
name: "as current user",
args: []string{"run", "dir", "--as-current-user"},
path: "dir",
expectedStruct: &runfn.RunFns{
Path: "dir",
AsCurrentUser: true,
Env: []string{},
},
},
}
for i := range tests {