Skip to content

Commit

Permalink
Etag support for ACM service perimeters (GoogleCloudPlatform#12363)
Browse files Browse the repository at this point in the history
  • Loading branch information
coder-221 authored Nov 22, 2024
1 parent 4d2543e commit 161220a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mmv1/products/accesscontextmanager/ServicePerimeter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ async:
custom_code:
constants: 'templates/terraform/constants/access_context_manager.go.tmpl'
encoder: 'templates/terraform/encoders/access_level_never_send_parent.go.tmpl'
pre_update: 'templates/terraform/pre_update/access_context_manager_service_perimeter.go.tmpl'
custom_import: 'templates/terraform/custom_import/set_access_policy_parent_from_self_link.go.tmpl'
# Skipping the sweeper due to the non-standard base_url
exclude_sweeper: true
Expand Down Expand Up @@ -788,3 +789,10 @@ properties:
actually enforcing them. This testing is done through analyzing the differences
between currently enforced and suggested restrictions. useExplicitDryRunSpec must
bet set to True if any of the fields in the spec are set to non-default values.
- name: 'etag'
type: Fingerprint
description: |
An opaque identifier for the current version of the ServicePerimeter. This
identifier does not follow any specific format. If an etag is not provided, the
operation will be performed as if a valid etag is provided.
output: true
7 changes: 7 additions & 0 deletions mmv1/products/accesscontextmanager/ServicePerimeters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ properties:
description: |
Description of the ServicePerimeter and its use. Does not affect
behavior.
- name: 'etag'
type: Fingerprint
description: |
An opaque identifier for the current version of the ServicePerimeter. This
identifier does not follow any specific format. If an etag is not provided, the
operation will be performed as if a valid etag is provided.
output: true
- name: 'createTime'
type: Time
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.Reso
"perimeter_type": flattenAccessContextManagerServicePerimetersServicePerimetersPerimeterType(original["perimeterType"], d, config),
"status": flattenAccessContextManagerServicePerimetersServicePerimetersStatus(original["status"], d, config),
"spec": flattenAccessContextManagerServicePerimetersServicePerimetersSpec(original["spec"], d, config),
"etag": flattenAccessContextManagerServicePerimetersServicePerimetersEtag(original["etag"], d, config),
"use_explicit_dry_run_spec": flattenAccessContextManagerServicePerimetersServicePerimetersUseExplicitDryRunSpec(original["useExplicitDryRunSpec"], d, config),
})
}
Expand All @@ -38,6 +39,10 @@ func flattenAccessContextManagerServicePerimetersServicePerimetersName(v interfa
return v
}

func flattenAccessContextManagerServicePerimetersServicePerimetersEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenAccessContextManagerServicePerimetersServicePerimetersTitle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if _, ok := d.GetOkExists("etag"); ok {
updateMask = append(updateMask, "etag")

url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func testAccAccessContextManagerServicePerimeter_basicTest(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccAccessContextManagerServicePerimeter_basic(org, "my policy", "level", "perimeter"),
Check: resource.TestCheckResourceAttrSet("google_access_context_manager_service_perimeter.test-access", "etag"),
},
{
ResourceName: "google_access_context_manager_service_perimeter.test-access",
Expand Down

0 comments on commit 161220a

Please sign in to comment.