mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-16 07:00:13 +01:00
fix environment variable names
This commit is contained in:
parent
859fd0c1c8
commit
909c90a558
1 changed files with 22 additions and 3 deletions
|
|
@ -330,10 +330,29 @@ Should only be used for testing.`)
|
|||
|
||||
}
|
||||
|
||||
// SetDefaults provides default values for environment variables
|
||||
func SetDefaults() {
|
||||
day := (time.Hour * 24).Seconds()
|
||||
func mustBindEnv(flag string, env string) {
|
||||
if err := viper.BindEnv(flag, env); err != nil {
|
||||
log.Fatalf("failed to bind env %q to flag %q: %v", env, flag, err)
|
||||
}
|
||||
}
|
||||
|
||||
// SetEnvBindings binds environment variables to their corresponding config keys
|
||||
func SetEnvBindings() {
|
||||
|
||||
// Using WATCHTOWER as a prefix...
|
||||
viper.SetEnvPrefix("WATCHTOWER")
|
||||
// ...and replacing dashes with undescores
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
||||
// ...map all environment variables to corresponding flags in upper case
|
||||
viper.AutomaticEnv()
|
||||
|
||||
// Aliases for non-matching ENV keys (backwards compability)
|
||||
mustBindEnv("interval", "WATCHTOWER_POLL_INTERVAL")
|
||||
|
||||
// Aliases for DOCKER_-prefixed env variables (matching those used for docker cli)
|
||||
mustBindEnv("host", "DOCKER_HOST")
|
||||
mustBindEnv("tlsverify", "DOCKER_TLS_VERIFY")
|
||||
mustBindEnv("api-version", "DOCKER_API_VERSION")
|
||||
}
|
||||
|
||||
// BindViperFlags binds the cmd PFlags to the viper configuration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue