Skip to content

Commit

Permalink
Don't send labels in POST request to create PSC forwarding rules (#11344
Browse files Browse the repository at this point in the history
)
  • Loading branch information
zli82016 authored Aug 5, 2024
1 parent a4f5531 commit f3c0eac
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions mmv1/products/compute/ForwardingRule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ examples:
- "port_range"
- "target"
custom_code: !ruby/object:Provider::Terraform::CustomCode
pre_create: templates/terraform/pre_create/compute_forwarding_rule.go.erb
post_create: templates/terraform/post_create/labels.erb
constants: 'templates/terraform/constants/compute_forwarding_rule.go.erb'
custom_diff: [
Expand Down
1 change: 1 addition & 0 deletions mmv1/products/compute/go_ForwardingRule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ async:
message: 'message'
collection_url_key: 'items'
custom_code:
pre_create: templates/terraform/pre_create/compute_forwarding_rule.go.tmpl
constants: 'templates/terraform/constants/go/compute_forwarding_rule.go.tmpl'
post_create: 'templates/terraform/post_create/go/labels.tmpl'
custom_diff:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Labels cannot be set in a create for PSC forwarding rules, so remove it from the CREATE request.
if targetProp != nil && strings.Contains(targetProp.(string), "/serviceAttachments/") {
if _, ok := obj["labels"]; ok {
delete(obj, "labels")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Labels cannot be set in a create for PSC forwarding rules, so remove it from the CREATE request.
if targetProp != nil && strings.Contains(targetProp.(string), "/serviceAttachments/") {
if _, ok := obj["labels"]; ok {
delete(obj, "labels")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func TestAccComputeForwardingRule_forwardingRuleVpcPscExampleUpdate(t *testing.T
ResourceName: "google_compute_forwarding_rule.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
},
{
Config: testAccComputeForwardingRule_forwardingRuleVpcPscExampleUpdate(context, false),
Expand All @@ -199,6 +200,7 @@ func TestAccComputeForwardingRule_forwardingRuleVpcPscExampleUpdate(t *testing.T
ResourceName: "google_compute_forwarding_rule.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
},
},
})
Expand Down Expand Up @@ -648,6 +650,9 @@ resource "google_compute_forwarding_rule" "default" {
ip_address = google_compute_address.consumer_address.id
allow_psc_global_access = false
%{lifecycle_block}
labels = {
"foo" = "bar"
}
}

// Consumer service endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func TestAccComputeForwardingRule_forwardingRuleVpcPscExampleUpdate(t *testing.T
ResourceName: "google_compute_forwarding_rule.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
},
{
Config: testAccComputeForwardingRule_forwardingRuleVpcPscExampleUpdate(context, false),
Expand All @@ -200,6 +201,7 @@ func TestAccComputeForwardingRule_forwardingRuleVpcPscExampleUpdate(t *testing.T
ResourceName: "google_compute_forwarding_rule.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
},
},
})
Expand Down Expand Up @@ -649,6 +651,9 @@ resource "google_compute_forwarding_rule" "default" {
ip_address = google_compute_address.consumer_address.id
allow_psc_global_access = false
%{lifecycle_block}
labels = {
"foo" = "bar"
}
}

// Consumer service endpoint
Expand Down

0 comments on commit f3c0eac

Please sign in to comment.