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

azurerm_container_registry - add supports for region_endpoint_enabled #13767

Merged
merged 2 commits into from
Oct 21, 2021
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
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
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