From 60bde0b49a912e2d78152576c362776c797ff702 Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Mon, 19 Feb 2024 18:25:00 +0100 Subject: [PATCH] Values without a backing env var should not be expanded --- cmd/backup/config_provider.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/backup/config_provider.go b/cmd/backup/config_provider.go index 4225d708..8cda171b 100644 --- a/cmd/backup/config_provider.go +++ b/cmd/backup/config_provider.go @@ -103,7 +103,12 @@ func loadConfigsFromEnvFiles(directory string) ([]*Config, error) { if err != nil { return nil, errwrap.Wrap(err, fmt.Sprintf("error reading %s", item.Name())) } - envFile, err := godotenv.Unmarshal(os.ExpandEnv(string(f))) + envFile, err := godotenv.Unmarshal(os.Expand(string(f), func(s string) string { + if val, ok := os.LookupEnv(s); ok { + return val + } + return s + })) if err != nil { return nil, errwrap.Wrap(err, fmt.Sprintf("error reading config file %s", p)) }