Skip to content

Commit 017c4ae

Browse files
authored
Merge pull request #245 from Liujingfang1/output
Add -o flag to kustomize build
2 parents bc2d69f + 7b2baad commit 017c4ae

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/commands/build.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
type buildOptions struct {
3434
kustomizationPath string
35+
outputPath string
3536
}
3637

3738
// newCmdBuild creates a new build command.
@@ -52,6 +53,10 @@ func newCmdBuild(out io.Writer, fs fs.FileSystem) *cobra.Command {
5253
return o.RunBuild(out, fs)
5354
},
5455
}
56+
cmd.Flags().StringVarP(
57+
&o.outputPath,
58+
"output", "o", "",
59+
"If specified, write the build output to this path.")
5560
return cmd
5661
}
5762

@@ -98,6 +103,10 @@ func (o *buildOptions) RunBuild(out io.Writer, fSys fs.FileSystem) error {
98103
if err != nil {
99104
return err
100105
}
106+
107+
if o.outputPath != "" {
108+
return fSys.WriteFile(o.outputPath, res)
109+
}
101110
_, err = out.Write(res)
102111
return err
103112
}

0 commit comments

Comments
 (0)