1
0
mirror of https://github.com/offen/docker-volume-backup.git synced 2025-11-23 21:44:40 +02:00

Env vars should propagate when using conf.d (#358)

* Extend confd test case to test for env var propagation

* Env vars set in conf.d files are expected to propagate

* Lock needs to be acquired when instantiating script
This commit is contained in:
Frederik Ring
2024-02-13 15:43:04 +01:00
committed by GitHub
parent 241b5d2f25
commit 9a1e885138
7 changed files with 68 additions and 42 deletions

View File

@@ -49,8 +49,9 @@ func loadEnvVars() (*Config, error) {
}
type configFile struct {
name string
config *Config
name string
config *Config
additionalEnvVars map[string]string
}
func loadEnvFiles(directory string) ([]configFile, error) {
@@ -74,13 +75,16 @@ func loadEnvFiles(directory string) ([]configFile, error) {
}
lookup := func(key string) (string, bool) {
val, ok := envFile[key]
return val, ok
if ok {
return val, ok
}
return os.LookupEnv(key)
}
c, err := loadConfig(lookup)
if err != nil {
return nil, fmt.Errorf("loadEnvFiles: error loading config from file %s: %w", p, err)
}
cs = append(cs, configFile{config: c, name: item.Name()})
cs = append(cs, configFile{config: c, name: item.Name(), additionalEnvVars: envFile})
}
return cs, nil