Skip to content

Commit

Permalink
fix(GROW-2931): GCP default label should be attributes (#1636)
Browse files Browse the repository at this point in the history
Signed-off-by: Lei Jin <[email protected]>
  • Loading branch information
leijin-lw authored Jun 5, 2024
1 parent 6d76586 commit e575eac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
16 changes: 4 additions & 12 deletions lwgenerate/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,20 +589,12 @@ func createGcpProvider(
attrs["region"] = region
}

modifiers := []lwgenerate.HclProviderModifier{
lwgenerate.HclProviderWithAttributes(attrs),
if len(providerDefaultLabels) != 0 {
attrs["default_labels"] = providerDefaultLabels
}

if len(providerDefaultLabels) != 0 {
defaultLabelsBlock, err := lwgenerate.HclCreateGenericBlock(
"default_labels",
nil,
providerDefaultLabels,
)
if err != nil {
return nil, err
}
modifiers = append(modifiers, lwgenerate.HclProviderWithGenericBlocks(defaultLabelsBlock))
modifiers := []lwgenerate.HclProviderModifier{
lwgenerate.HclProviderWithAttributes(attrs),
}

provider, err := lwgenerate.NewProvider(
Expand Down
7 changes: 3 additions & 4 deletions lwgenerate/gcp/gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,13 +921,12 @@ var gcpProviderWithExtraArguments = `provider "google" {
var gcpProviderWithDefaultLabels = `provider "google" {
alias = "us-east1"
credentials = "/path/to/credentials"
project = "project1"
region = "us-east1"
default_labels {
default_labels = {
LABEL_TEST = "foo"
LABEL_TEST1 = "bar"
}
project = "project1"
region = "us-east1"
}
`

Expand Down

0 comments on commit e575eac

Please sign in to comment.