Skip to content
Open
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
9 changes: 8 additions & 1 deletion bundle/deploy/terraform/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,19 @@ func inheritEnvVars(ctx context.Context, environ map[string]string) error {
}

// If there's SYSTEM_ACCESSTOKEN set, we need to pass the value of the environment variable to Terraform.
// This is necessary to ensure that Terraform can use the same access token as the CLI.
// This is necessary to ensure that Terraform can use the same access token as the CLI for Azure DevOps OIDC auth.
systemAccessToken, ok := env.Lookup(ctx, "SYSTEM_ACCESSTOKEN")
if ok {
environ["SYSTEM_ACCESSTOKEN"] = systemAccessToken
}

// If there's SYSTEM_TEAMFOUNDATIONCOLLECTIONURI set, we need to pass the value of the environment variable to Terraform.
// This is necessary for Azure DevOps OIDC auth to work properly.
systemCollectionUri, ok := env.Lookup(ctx, "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI")
if ok {
environ["SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"] = systemCollectionUri
}

// Map $DATABRICKS_TF_CLI_CONFIG_FILE to $TF_CLI_CONFIG_FILE
// VSCode extension provides a file with the "provider_installation.filesystem_mirror" configuration.
// We only use it if the provider version matches the currently used version,
Expand Down
10 changes: 10 additions & 0 deletions bundle/deploy/terraform/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ func TestInheritSystemAccessToken(t *testing.T) {
assert.Equal(t, "foobar", env["SYSTEM_ACCESSTOKEN"])
}

func TestInheritSystemTeamFoundationCollectionUri(t *testing.T) {
t.Setenv("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "foobar")

ctx := context.Background()
env := map[string]string{}
err := inheritEnvVars(ctx, env)
require.NoError(t, err)
assert.Equal(t, "foobar", env["SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"])
}

func TestSetUserProfileFromInheritEnvVars(t *testing.T) {
t.Setenv("USERPROFILE", "c:\\foo\\c")

Expand Down