mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Merge pull request #3097 from Shell32-Natsu/as-current-user
add --as-current-user flag to fn run
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user