Skip to content

Commit

Permalink
azurerm_container_registry - add supports for `region_endpoint_enab…
Browse files Browse the repository at this point in the history
…led` (#13767)
  • Loading branch information
magodo authored Oct 21, 2021
1 parent 6673d92 commit b2dac80
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/services/containers/container_registry_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ func resourceContainerRegistry() *pluginsdk.Resource {
Default: false,
},

"regional_endpoint_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
},

"tags": tags.Schema(),
},
},
Expand Down Expand Up @@ -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["regional_endpoint_enabled"] = value.RegionEndpointEnabled != nil && *value.RegionEndpointEnabled
geoReplications = append(geoReplications, replication)
}
}
Expand Down Expand Up @@ -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["regional_endpoint_enabled"].(bool)),
},
})
}
Expand Down
37 changes: 37 additions & 0 deletions internal/services/containers/container_registry_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
regional_endpoint_enabled = true
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Secondary)
}
2 changes: 2 additions & 0 deletions website/docs/r/container_registry.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

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

* `trust_policy` - (Optional) A `trust_policy` block as documented below.
Expand Down

0 comments on commit b2dac80

Please sign in to comment.