From b53db4ef14856250bfa64863e6dcd4b6fcf13b67 Mon Sep 17 00:00:00 2001 From: Craig Sloggett Date: Fri, 22 Mar 2024 09:14:31 -0400 Subject: [PATCH] Ensure environment variables are set when interpolating rawPath --- internal/command/cliconfig/provider_installation.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/command/cliconfig/provider_installation.go b/internal/command/cliconfig/provider_installation.go index 3a92b47ec0..40a407d1ec 100644 --- a/internal/command/cliconfig/provider_installation.go +++ b/internal/command/cliconfig/provider_installation.go @@ -254,7 +254,18 @@ func decodeProviderInstallationFromConfig(hclFile *hclast.File) ([]*ProviderInst )) continue } - interpolatedPath := os.ExpandEnv(rawPath) + interpolatedPath := os.Expand(rawPath, func(envVarName string) string { + if value, ok := os.LookupEnv(envVarName); ok { + return value + } else { + diags = diags.Append(tfdiags.Sourceless( + tfdiags.Error, + "Interpolated environment variable not set", + fmt.Sprintf("The environment variable %s is not set or empty and can result in undesired behavior", envVarName), + )) + return "" + } + }) dirPath := filepath.Clean(interpolatedPath) devOverrides[addr] = getproviders.PackageLocalDir(dirPath) }