diff --git a/cmd/crane/cmd/mutate.go b/cmd/crane/cmd/mutate.go index a99def0e9..a113b4251 100644 --- a/cmd/crane/cmd/mutate.go +++ b/cmd/crane/cmd/mutate.go @@ -37,6 +37,7 @@ func NewCmdMutate(options *[]crane.Option) *cobra.Command { var newRef string var newRepo string var user string + var workdir string mutateCmd := &cobra.Command{ Use: "mutate", @@ -114,6 +115,11 @@ func NewCmdMutate(options *[]crane.Option) *cobra.Command { cfg.Config.User = user } + // Set workdir. + if len(workdir) > 0 { + cfg.Config.WorkingDir = workdir + } + // Mutate and write image. img, err = mutate.Config(img, cfg.Config) if err != nil { @@ -165,6 +171,7 @@ func NewCmdMutate(options *[]crane.Option) *cobra.Command { mutateCmd.Flags().StringVarP(&outFile, "output", "o", "", "Path to new tarball of resulting image") mutateCmd.Flags().StringSliceVar(&newLayers, "append", []string{}, "Path to tarball to append to image") mutateCmd.Flags().StringVarP(&user, "user", "u", "", "New user to set") + mutateCmd.Flags().StringVarP(&workdir, "workdir", "w", "", "New working dir to set") return mutateCmd } diff --git a/cmd/crane/doc/crane_mutate.md b/cmd/crane/doc/crane_mutate.md index 0174b09d8..76e81a0be 100644 --- a/cmd/crane/doc/crane_mutate.md +++ b/cmd/crane/doc/crane_mutate.md @@ -20,6 +20,7 @@ crane mutate [flags] --repo string Repository to push the mutated image to. If provided, push by digest to this repository. -t, --tag string New tag reference to apply to mutated image. If not provided, push by digest to the original image repository. -u, --user string New user to set + -w, --workdir string New working dir to set ``` ### Options inherited from parent commands