Add -o flag to kustomize build

This commit is contained in:
Jingfang Liu
2018-08-09 13:15:39 -07:00
parent 7d38916d63
commit 7b2baad390

View File

@@ -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
}