Skip to content

Commit

Permalink
Merge pull request #245 from Liujingfang1/output
Browse files Browse the repository at this point in the history
Add -o flag to kustomize build
  • Loading branch information
monopole committed Aug 9, 2018
2 parents bc2d69f + 7b2baad commit 017c4ae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

type buildOptions struct {
kustomizationPath string
outputPath string
}

// newCmdBuild creates a new build command.
Expand All @@ -52,6 +53,10 @@ func newCmdBuild(out io.Writer, fs fs.FileSystem) *cobra.Command {
return o.RunBuild(out, fs)
},
}
cmd.Flags().StringVarP(
&o.outputPath,
"output", "o", "",
"If specified, write the build output to this path.")
return cmd
}

Expand Down Expand Up @@ -98,6 +103,10 @@ func (o *buildOptions) RunBuild(out io.Writer, fSys fs.FileSystem) error {
if err != nil {
return err
}

if o.outputPath != "" {
return fSys.WriteFile(o.outputPath, res)
}
_, err = out.Write(res)
return err
}

0 comments on commit 017c4ae

Please sign in to comment.