From 7b2baad390a3d80c38e531fd4a206a30da8b6ea8 Mon Sep 17 00:00:00 2001 From: Jingfang Liu Date: Thu, 9 Aug 2018 13:15:39 -0700 Subject: [PATCH] Add -o flag to kustomize build --- pkg/commands/build.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/commands/build.go b/pkg/commands/build.go index a270053c4..3b5941803 100644 --- a/pkg/commands/build.go +++ b/pkg/commands/build.go @@ -32,6 +32,7 @@ import ( type buildOptions struct { kustomizationPath string + outputPath string } // newCmdBuild creates a new build command. @@ -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 } @@ -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 }