Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Etag support for ACM service perimeters #20455

Merged
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
3 changes: 3 additions & 0 deletions .changelog/12363.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
accesscontextmanager: added `etag` to `google_access_context_manager_service_perimeter` and `google_access_context_manager_service_perimeters`
```
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,13 @@ bet set to True if any of the fields in the spec are set to non-default values.`
Computed: true,
Description: `Time the AccessPolicy was created in UTC.`,
},
"etag": {
Type: schema.TypeString,
Computed: true,
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.`,
},
"update_time": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -963,6 +970,12 @@ func resourceAccessContextManagerServicePerimeterCreate(d *schema.ResourceData,
} else if v, ok := d.GetOkExists("use_explicit_dry_run_spec"); !tpgresource.IsEmptyValue(reflect.ValueOf(useExplicitDryRunSpecProp)) && (ok || !reflect.DeepEqual(v, useExplicitDryRunSpecProp)) {
obj["useExplicitDryRunSpec"] = useExplicitDryRunSpecProp
}
etagProp, err := expandAccessContextManagerServicePerimeterEtag(d.Get("etag"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("etag"); !tpgresource.IsEmptyValue(reflect.ValueOf(etagProp)) && (ok || !reflect.DeepEqual(v, etagProp)) {
obj["etag"] = etagProp
}
parentProp, err := expandAccessContextManagerServicePerimeterParent(d.Get("parent"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -1108,6 +1121,9 @@ func resourceAccessContextManagerServicePerimeterRead(d *schema.ResourceData, me
if err := d.Set("use_explicit_dry_run_spec", flattenAccessContextManagerServicePerimeterUseExplicitDryRunSpec(res["useExplicitDryRunSpec"], d, config)); err != nil {
return fmt.Errorf("Error reading ServicePerimeter: %s", err)
}
if err := d.Set("etag", flattenAccessContextManagerServicePerimeterEtag(res["etag"], d, config)); err != nil {
return fmt.Errorf("Error reading ServicePerimeter: %s", err)
}
if err := d.Set("name", flattenAccessContextManagerServicePerimeterName(res["name"], d, config)); err != nil {
return fmt.Errorf("Error reading ServicePerimeter: %s", err)
}
Expand Down Expand Up @@ -1155,6 +1171,12 @@ func resourceAccessContextManagerServicePerimeterUpdate(d *schema.ResourceData,
} else if v, ok := d.GetOkExists("use_explicit_dry_run_spec"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, useExplicitDryRunSpecProp)) {
obj["useExplicitDryRunSpec"] = useExplicitDryRunSpecProp
}
etagProp, err := expandAccessContextManagerServicePerimeterEtag(d.Get("etag"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("etag"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, etagProp)) {
obj["etag"] = etagProp
}

obj, err = resourceAccessContextManagerServicePerimeterEncoder(d, meta, obj)
if err != nil {
Expand Down Expand Up @@ -1196,12 +1218,21 @@ func resourceAccessContextManagerServicePerimeterUpdate(d *schema.ResourceData,
if d.HasChange("use_explicit_dry_run_spec") {
updateMask = append(updateMask, "useExplicitDryRunSpec")
}

if d.HasChange("etag") {
updateMask = append(updateMask, "etag")
}
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
// won't set it
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
if err != nil {
return err
}
if _, ok := d.GetOkExists("etag"); ok {
updateMask = append(updateMask, "etag")

url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
}

// err == nil indicates that the billing_project value was found
if bp, err := tpgresource.GetBillingProject(d, config); err == nil {
Expand Down Expand Up @@ -2085,6 +2116,10 @@ func flattenAccessContextManagerServicePerimeterUseExplicitDryRunSpec(v interfac
return v
}

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

func flattenAccessContextManagerServicePerimeterName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
Expand Down Expand Up @@ -3173,6 +3208,10 @@ func expandAccessContextManagerServicePerimeterUseExplicitDryRunSpec(v interface
return v, nil
}

func expandAccessContextManagerServicePerimeterEtag(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandAccessContextManagerServicePerimeterParent(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,13 @@ bet set to True if any of the fields in the spec are set to non-default values.`
Computed: true,
Description: `Time the AccessPolicy was created in UTC.`,
},
"etag": {
Type: schema.TypeString,
Computed: true,
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.`,
},
"update_time": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -1116,6 +1123,7 @@ func flattenAccessContextManagerServicePerimetersServicePerimeters(v interface{}
"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 @@ -1136,6 +1144,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 Expand Up @@ -1939,6 +1951,13 @@ func expandAccessContextManagerServicePerimetersServicePerimeters(v interface{},
transformed["description"] = transformedDescription
}

transformedEtag, err := expandAccessContextManagerServicePerimetersServicePerimetersEtag(original["etag"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedEtag); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["etag"] = transformedEtag
}

transformedCreateTime, err := expandAccessContextManagerServicePerimetersServicePerimetersCreateTime(original["create_time"], d, config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -1998,6 +2017,10 @@ func expandAccessContextManagerServicePerimetersServicePerimetersDescription(v i
return v, nil
}

func expandAccessContextManagerServicePerimetersServicePerimetersEtag(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandAccessContextManagerServicePerimetersServicePerimetersCreateTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,11 @@ In addition to the arguments listed above, the following computed attributes are
* `update_time` -
Time the AccessPolicy was updated in UTC.

* `etag` -
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.


## Timeouts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ The following arguments are supported:
Description of the ServicePerimeter and its use. Does not affect
behavior.

* `etag` -
(Output)
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.

* `create_time` -
(Output)
Time the AccessPolicy was created in UTC.
Expand Down