Merge pull request #108 from gravitational/alexander/env

Alexander/env
This commit is contained in:
alexlyulkov 2016-02-05 15:46:03 +03:00
commit e5cb47e168
2 changed files with 11 additions and 3 deletions

View file

@ -4,7 +4,8 @@
{"name": "os", "value": "linux"}
],
"commands": [
{"name": "start", "args": ["rootfs/usr/bin/teleport", "--env"]}
{"name": "start", "args": ["rootfs/usr/bin/teleport", "--env"]},
{"name": "tctl", "args": ["rootfs/usr/bin/tctl", "--env"]}
],
"config": {
"params": [

View file

@ -59,6 +59,7 @@ func (cmd *Command) SetOut(out io.Writer) {
func (cmd *Command) Run(args []string) error {
app := kingpin.New("tctl", "CLI for key management of teleport SSH cluster")
configPath := app.Flag("config", "Path to the Teleport configuration file").Default(DefaultConfigPath).String()
useEnv := app.Flag("env", "read configuration parameters from environment").Default("false").Bool()
// SSH Key pair
keyPair := app.Command("keypair", "Helper operations with SSH keypairs")
@ -198,9 +199,15 @@ func (cmd *Command) Run(args []string) error {
if !strings.HasPrefix(selectedCommand, agent.FullCommand()) {
var cfg service.Config
if *useEnv {
if err := service.ParseEnv(&cfg); err != nil {
return trace.Wrap(err)
}
} else {
if err := service.ParseYAMLFile(*configPath, &cfg); err != nil {
return trace.Wrap(err)
}
}
service.SetDefaults(&cfg)
if cfg.Auth.Enabled && len(cfg.AuthServers) == 0 {
cfg.AuthServers = []utils.NetAddr{cfg.Auth.SSHAddr}