Merge pull request #245 from Liujingfang1/output

Add -o flag to kustomize build
This commit is contained in:
Jeff Regan
2018-08-09 16:49:25 -07:00
committed by GitHub

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
}