1
0
mirror of https://github.com/rancher/os.git synced 2025-06-27 23:36:49 +00:00

Add --input flag to ros config merge

This commit is contained in:
Josh Curl 2016-06-14 15:05:12 -07:00
parent a002939a3f
commit d205af4abf
No known key found for this signature in database
GPG Key ID: 82B504B9BCCFA677

View File

@ -69,6 +69,12 @@ func configSubcommands() []cli.Command {
Name: "merge",
Usage: "merge configuration from stdin",
Action: merge,
Flags: []cli.Flag{
cli.StringFlag{
Name: "input, i",
Usage: "File from which to read",
},
},
},
}
}
@ -180,13 +186,23 @@ func configGet(c *cli.Context) error {
}
func merge(c *cli.Context) error {
bytes, err := ioutil.ReadAll(os.Stdin)
input := os.Stdin
inputFile := c.String("input")
if inputFile != "" {
var err error
input, err = os.Open(inputFile)
if err != nil {
log.Fatal(err)
}
defer input.Close()
}
bytes, err := ioutil.ReadAll(input)
if err != nil {
log.Fatal(err)
}
err = config.Merge(bytes)
if err != nil {
if err = config.Merge(bytes); err != nil {
log.Fatal(err)
}