Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conf files should expand env vars #363

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading