uswitch / vault-creds

Sidecar container for requesting dynamic Vault database secrets
Apache License 2.0
84 stars 14 forks source link

Read Variables from ENV #25

Open Shrumplestiltskin opened 5 years ago

Shrumplestiltskin commented 5 years ago

It could be advantageous in some instances to have variables read from the container environment rather than passing command flags to the binary.

Joseph-Irving commented 5 years ago

Yeah, this seems like a reasonable thing to do, might look at switching to https://github.com/spf13/viper so that we can easily switch between flags, env and config file

arnitolog commented 5 years ago

I guess you don't need to switch to any other packet since you are already using kingpin. So you can easily add Env Vars: vaultAddr = kingpin.Flag("vault-addr", "Vault address, e.g. https://vault:8200").Envar("VAULT_ADDR").String() https://godoc.org/github.com/alecthomas/kingpin#FlagClause.Envar

Joseph-Irving commented 5 years ago

true, I'm just thinking ahead as people might want a config file in the future

arnitolog commented 5 years ago

It looks like kingpin also has an option to read args from the config file: https://godoc.org/github.com/alecthomas/kingpin#ExpandArgsFromFile

Joseph-Irving commented 5 years ago

I think the problem with Kingpin was easily overriding, based on flag/file/env etc. See this issue https://github.com/alecthomas/kingpin/issues/208, however it looks like something has been implemented to try and make this better https://github.com/alecthomas/kingpin/pull/209, so that could be worth a look. Although it's only on v3-unstable branch