allow to specify CLI options via environment vars
Use `git show -w` to inspect this commit diff since it changes whitespace due to `gofmt`. This commit allows to use environment variables in place of CLI parameters to change program behavior. This supports the notion of [12-factor apps](http://12factor.net/) and makes it easier to dockerize the app as well as create a systemd unit file. It establishes a pattern of `MGMT_*` naming convention for environment variables.
This commit is contained in:
4
main.go
4
main.go
@@ -228,6 +228,7 @@ func main() {
|
||||
Name: "file, f",
|
||||
Value: "",
|
||||
Usage: "graph definition to run",
|
||||
EnvVar: "MGMT_FILE",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "no-watch",
|
||||
@@ -259,16 +260,19 @@ func main() {
|
||||
Name: "seed, s",
|
||||
Value: "",
|
||||
Usage: "default etc peer endpoint",
|
||||
EnvVar: "MGMT_SEED_ENDPOINT",
|
||||
},
|
||||
cli.IntFlag{
|
||||
Name: "converged-timeout, t",
|
||||
Value: -1,
|
||||
Usage: "exit after approximately this many seconds in a converged state",
|
||||
EnvVar: "MGMT_CONVERGED_TIMEOUT",
|
||||
},
|
||||
cli.IntFlag{
|
||||
Name: "max-runtime",
|
||||
Value: 0,
|
||||
Usage: "exit after a maximum of approximately this many seconds",
|
||||
EnvVar: "MGMT_MAX_RUNTIME",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user