From b9f1f5e4009d310770c571bf694ff8fc5878fec2 Mon Sep 17 00:00:00 2001 From: magodo Date: Mon, 18 Oct 2021 14:47:08 +0800 Subject: [PATCH 1/2] `azurerm_container_registry` - add supports for `region_endpoint_enabled` --- .../containers/container_registry_resource.go | 9 ++++- .../container_registry_resource_test.go | 37 +++++++++++++++++++ .../docs/r/container_registry.html.markdown | 2 + 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/internal/services/containers/container_registry_resource.go b/internal/services/containers/container_registry_resource.go index 09e98a2163ed..46bcdf3c7436 100644 --- a/internal/services/containers/container_registry_resource.go +++ b/internal/services/containers/container_registry_resource.go @@ -120,6 +120,11 @@ func resourceContainerRegistry() *pluginsdk.Resource { Default: false, }, + "region_endpoint_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + }, + "tags": tags.Schema(), }, }, @@ -813,6 +818,7 @@ func resourceContainerRegistryRead(d *pluginsdk.ResourceData, meta interface{}) replication["location"] = valueLocation replication["tags"] = tags.Flatten(value.Tags) replication["zone_redundancy_enabled"] = value.ZoneRedundancy == containerregistry.ZoneRedundancyEnabled + replication["region_endpoint_enabled"] = value.RegionEndpointEnabled != nil && *value.RegionEndpointEnabled geoReplications = append(geoReplications, replication) } } @@ -959,7 +965,8 @@ func expandReplications(p []interface{}) []containerregistry.Replication { Name: &location, Tags: tags, ReplicationProperties: &containerregistry.ReplicationProperties{ - ZoneRedundancy: zoneRedundancy, + ZoneRedundancy: zoneRedundancy, + RegionEndpointEnabled: utils.Bool(value["region_endpoint_enabled"].(bool)), }, }) } diff --git a/internal/services/containers/container_registry_resource_test.go b/internal/services/containers/container_registry_resource_test.go index 97f5e0f5adf7..03925d20aecb 100644 --- a/internal/services/containers/container_registry_resource_test.go +++ b/internal/services/containers/container_registry_resource_test.go @@ -560,6 +560,21 @@ func TestAccContainerRegistry_geoReplicationZoneRedundancy(t *testing.T) { }) } +func TestAccContainerRegistry_geoReplicationRegionEndpoint(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_container_registry", "test") + r := ContainerRegistryResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.regionEndpoint(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (t ContainerRegistryResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := parse.RegistryID(state.ID) if err != nil { @@ -1151,3 +1166,25 @@ resource "azurerm_container_registry" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Secondary) } + +func (ContainerRegistryResource) regionEndpoint(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} +resource "azurerm_resource_group" "test" { + name = "acctestRG-acr-%d" + location = "%s" +} +resource "azurerm_container_registry" "test" { + name = "testacccr%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + sku = "Premium" + georeplications { + location = "%s" + region_endpoint_enabled = true + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Secondary) +} diff --git a/website/docs/r/container_registry.html.markdown b/website/docs/r/container_registry.html.markdown index f2408bdcc9cc..c315df54d720 100644 --- a/website/docs/r/container_registry.html.markdown +++ b/website/docs/r/container_registry.html.markdown @@ -127,6 +127,8 @@ The following arguments are supported: * `quarantine_policy_enabled` - (Optional) Boolean value that indicates whether quarantine policy is enabled. Defaults to `false`. +* `region_endpoint_enabled` - (Optional) Whether regional endpoint is enabled for this Container Registry? Defaults to `false`. + * `retention_policy` - (Optional) A `retention_policy` block as documented below. * `trust_policy` - (Optional) A `trust_policy` block as documented below. From eb87a207cbb3cea7e3c2ff3889dec80dd2a6f97e Mon Sep 17 00:00:00 2001 From: magodo Date: Thu, 21 Oct 2021 12:44:24 +0800 Subject: [PATCH 2/2] rename --- internal/services/containers/container_registry_resource.go | 6 +++--- .../services/containers/container_registry_resource_test.go | 4 ++-- website/docs/r/container_registry.html.markdown | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/services/containers/container_registry_resource.go b/internal/services/containers/container_registry_resource.go index 46bcdf3c7436..93a0f44b63f6 100644 --- a/internal/services/containers/container_registry_resource.go +++ b/internal/services/containers/container_registry_resource.go @@ -120,7 +120,7 @@ func resourceContainerRegistry() *pluginsdk.Resource { Default: false, }, - "region_endpoint_enabled": { + "regional_endpoint_enabled": { Type: pluginsdk.TypeBool, Optional: true, }, @@ -818,7 +818,7 @@ func resourceContainerRegistryRead(d *pluginsdk.ResourceData, meta interface{}) replication["location"] = valueLocation replication["tags"] = tags.Flatten(value.Tags) replication["zone_redundancy_enabled"] = value.ZoneRedundancy == containerregistry.ZoneRedundancyEnabled - replication["region_endpoint_enabled"] = value.RegionEndpointEnabled != nil && *value.RegionEndpointEnabled + replication["regional_endpoint_enabled"] = value.RegionEndpointEnabled != nil && *value.RegionEndpointEnabled geoReplications = append(geoReplications, replication) } } @@ -966,7 +966,7 @@ func expandReplications(p []interface{}) []containerregistry.Replication { Tags: tags, ReplicationProperties: &containerregistry.ReplicationProperties{ ZoneRedundancy: zoneRedundancy, - RegionEndpointEnabled: utils.Bool(value["region_endpoint_enabled"].(bool)), + RegionEndpointEnabled: utils.Bool(value["regional_endpoint_enabled"].(bool)), }, }) } diff --git a/internal/services/containers/container_registry_resource_test.go b/internal/services/containers/container_registry_resource_test.go index 03925d20aecb..1d6a30e3061c 100644 --- a/internal/services/containers/container_registry_resource_test.go +++ b/internal/services/containers/container_registry_resource_test.go @@ -1182,8 +1182,8 @@ resource "azurerm_container_registry" "test" { location = azurerm_resource_group.test.location sku = "Premium" georeplications { - location = "%s" - region_endpoint_enabled = true + location = "%s" + regional_endpoint_enabled = true } } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Secondary) diff --git a/website/docs/r/container_registry.html.markdown b/website/docs/r/container_registry.html.markdown index c315df54d720..0aba01365433 100644 --- a/website/docs/r/container_registry.html.markdown +++ b/website/docs/r/container_registry.html.markdown @@ -127,7 +127,7 @@ The following arguments are supported: * `quarantine_policy_enabled` - (Optional) Boolean value that indicates whether quarantine policy is enabled. Defaults to `false`. -* `region_endpoint_enabled` - (Optional) Whether regional endpoint is enabled for this Container Registry? Defaults to `false`. +* `regional_endpoint_enabled` - (Optional) Whether regional endpoint is enabled for this Container Registry? Defaults to `false`. * `retention_policy` - (Optional) A `retention_policy` block as documented below.