Skip to content

Commit

Permalink
Introduce endpoint global access field in endpoint attachment resourc…
Browse files Browse the repository at this point in the history
…e (#10632) (hashicorp#7443)

[upstream:48dec2af5cf1b80049cdfe22b02eaea8ad9c1146]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored May 31, 2024
1 parent 1a3b095 commit 265c6c2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func ResourceIntegrationConnectorsEndpointAttachment() *schema.Resource {
Optional: true,
Description: `Description of the resource.`,
},
"endpoint_global_access": {
Type: schema.TypeBool,
Optional: true,
Description: `Enable global access for endpoint attachment.`,
},
"labels": {
Type: schema.TypeMap,
Optional: true,
Expand Down Expand Up @@ -147,6 +152,12 @@ func resourceIntegrationConnectorsEndpointAttachmentCreate(d *schema.ResourceDat
} else if v, ok := d.GetOkExists("service_attachment"); !tpgresource.IsEmptyValue(reflect.ValueOf(serviceAttachmentProp)) && (ok || !reflect.DeepEqual(v, serviceAttachmentProp)) {
obj["serviceAttachment"] = serviceAttachmentProp
}
endpointGlobalAccessProp, err := expandIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(d.Get("endpoint_global_access"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("endpoint_global_access"); !tpgresource.IsEmptyValue(reflect.ValueOf(endpointGlobalAccessProp)) && (ok || !reflect.DeepEqual(v, endpointGlobalAccessProp)) {
obj["endpointGlobalAccess"] = endpointGlobalAccessProp
}
labelsProp, err := expandIntegrationConnectorsEndpointAttachmentEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -280,6 +291,9 @@ func resourceIntegrationConnectorsEndpointAttachmentRead(d *schema.ResourceData,
if err := d.Set("endpoint_ip", flattenIntegrationConnectorsEndpointAttachmentEndpointIp(res["endpointIp"], d, config)); err != nil {
return fmt.Errorf("Error reading EndpointAttachment: %s", err)
}
if err := d.Set("endpoint_global_access", flattenIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(res["endpointGlobalAccess"], d, config)); err != nil {
return fmt.Errorf("Error reading EndpointAttachment: %s", err)
}
if err := d.Set("terraform_labels", flattenIntegrationConnectorsEndpointAttachmentTerraformLabels(res["labels"], d, config)); err != nil {
return fmt.Errorf("Error reading EndpointAttachment: %s", err)
}
Expand Down Expand Up @@ -312,6 +326,12 @@ func resourceIntegrationConnectorsEndpointAttachmentUpdate(d *schema.ResourceDat
} else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
obj["description"] = descriptionProp
}
endpointGlobalAccessProp, err := expandIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(d.Get("endpoint_global_access"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("endpoint_global_access"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, endpointGlobalAccessProp)) {
obj["endpointGlobalAccess"] = endpointGlobalAccessProp
}
labelsProp, err := expandIntegrationConnectorsEndpointAttachmentEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return err
Expand All @@ -332,6 +352,10 @@ func resourceIntegrationConnectorsEndpointAttachmentUpdate(d *schema.ResourceDat
updateMask = append(updateMask, "description")
}

if d.HasChange("endpoint_global_access") {
updateMask = append(updateMask, "endpointGlobalAccess")
}

if d.HasChange("effective_labels") {
updateMask = append(updateMask, "labels")
}
Expand Down Expand Up @@ -489,6 +513,10 @@ func flattenIntegrationConnectorsEndpointAttachmentEndpointIp(v interface{}, d *
return v
}

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

func flattenIntegrationConnectorsEndpointAttachmentTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return v
Expand Down Expand Up @@ -516,6 +544,10 @@ func expandIntegrationConnectorsEndpointAttachmentServiceAttachment(v interface{
return v, nil
}

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

func expandIntegrationConnectorsEndpointAttachmentEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ resource "google_integration_connectors_endpoint_attachment" "sampleendpointatta
labels = {
foo = "bar"
}
endpoint_global_access = false
}
`, context)
}
Expand All @@ -76,6 +77,7 @@ resource "google_integration_connectors_endpoint_attachment" "sampleendpointatta
labels = {
bar = "foo"
}
endpoint_global_access = true
}
`, context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ The following arguments are supported:
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
Please refer to the field `effective_labels` for all of the labels present on the resource.

* `endpoint_global_access` -
(Optional)
Enable global access for endpoint attachment.

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

Expand Down

0 comments on commit 265c6c2

Please sign in to comment.