mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
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.Command.Flags().StringArrayVarP(
|
||||||
&r.Env, "env", "e", []string{},
|
&r.Env, "env", "e", []string{},
|
||||||
"a list of environment variables to be used by functions")
|
"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
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +99,7 @@ type RunFnRunner struct {
|
|||||||
Mounts []string
|
Mounts []string
|
||||||
LogSteps bool
|
LogSteps bool
|
||||||
Env []string
|
Env []string
|
||||||
|
AsCurrentUser bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RunFnRunner) runE(c *cobra.Command, args []string) error {
|
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,
|
ResultsDir: r.ResultsDir,
|
||||||
LogSteps: r.LogSteps,
|
LogSteps: r.LogSteps,
|
||||||
Env: r.Env,
|
Env: r.Env,
|
||||||
|
AsCurrentUser: r.AsCurrentUser,
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't consider args for the function
|
// don't consider args for the function
|
||||||
|
|||||||
@@ -300,6 +300,16 @@ apiVersion: v1
|
|||||||
Env: []string{"FOO=BAR", "BAR"},
|
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 {
|
for i := range tests {
|
||||||
|
|||||||
Reference in New Issue
Block a user