Skip to content

Commit

Permalink
Conf files should expand env vars (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
m90 authored Feb 15, 2024
1 parent 37f9bd9 commit a01fc3d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cmd/backup/config_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ func loadEnvFiles(directory string) ([]configFile, error) {
continue
}
p := filepath.Join(directory, item.Name())
envFile, err := godotenv.Read(p)
f, err := os.ReadFile(p)
if err != nil {
return nil, fmt.Errorf("loadEnvFiles: error reading %s: %w", item.Name(), err)
}
envFile, err := godotenv.Unmarshal(os.ExpandEnv(string(f)))
if err != nil {
return nil, fmt.Errorf("loadEnvFiles: error reading config file %s: %w", p, err)
}
Expand Down
2 changes: 1 addition & 1 deletion test/confd/01backup.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NAME="conf"
NAME="$EXPANSION_VALUE"
BACKUP_CRON_EXPRESSION="*/1 * * * *"
1 change: 1 addition & 0 deletions test/confd/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
environment:
BACKUP_FILENAME: $$NAME.tar.gz
BACKUP_FILENAME_EXPAND: 'true'
EXPANSION_VALUE: conf
volumes:
- ${LOCAL_DIR:-./local}:/archive
- app_data:/backup/app_data:ro
Expand Down

0 comments on commit a01fc3d

Please sign in to comment.