Skip to content

Commit

Permalink
Fix env variable for AzureCli local config (#2248)
Browse files Browse the repository at this point in the history
## Changes

Solves #1722 (current solution passes wrong variable)

## Tests

None, this is a simple find-and-replace on a previous PR.
Proof that this is the correct
[variable](https://learn.microsoft.com/en-us/cli/azure/azure-cli-configuration#cli-configuration-file).
This just passes the variable along to the Terraform environment, which
[should](hashicorp/terraform#25416) be picked
up by Terraform.

Co-authored-by: Rik Jansen <[email protected]>
  • Loading branch information
rikjansen-hu and RikJansenABN authored Feb 4, 2025
1 parent 84b694f commit dcc61cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bundle/deploy/terraform/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ var envCopy = []string{
// same auxiliary programs (e.g. `az`, or `gcloud`) as the CLI.
"PATH",

// Include $AZURE_CONFIG_FILE in set of environment variables to pass along.
// Include $AZURE_CONFIG_DIR in set of environment variables to pass along.
// This is set in Azure DevOps by the AzureCLI@2 task.
"AZURE_CONFIG_FILE",
"AZURE_CONFIG_DIR",

// Include $TF_CLI_CONFIG_FILE to override terraform provider in development.
// See: https://developer.hashicorp.com/terraform/cli/config/config-file#explicit-installation-method-configuration
Expand Down
4 changes: 2 additions & 2 deletions bundle/deploy/terraform/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func TestInheritEnvVars(t *testing.T) {
t.Setenv("HOME", "/home/testuser")
t.Setenv("PATH", "/foo:/bar")
t.Setenv("TF_CLI_CONFIG_FILE", "/tmp/config.tfrc")
t.Setenv("AZURE_CONFIG_FILE", "/tmp/foo/bar")
t.Setenv("AZURE_CONFIG_DIR", "/tmp/foo/bar")

ctx := context.Background()
env := map[string]string{}
Expand All @@ -301,7 +301,7 @@ func TestInheritEnvVars(t *testing.T) {
assert.Equal(t, "/home/testuser", env["HOME"])
assert.Equal(t, "/foo:/bar", env["PATH"])
assert.Equal(t, "/tmp/config.tfrc", env["TF_CLI_CONFIG_FILE"])
assert.Equal(t, "/tmp/foo/bar", env["AZURE_CONFIG_FILE"])
assert.Equal(t, "/tmp/foo/bar", env["AZURE_CONFIG_DIR"])
}
}

Expand Down

0 comments on commit dcc61cd

Please sign in to comment.