Skip to content

Commit

Permalink
Fixed for Ability to create Container Registry with zone redundancy (#…
Browse files Browse the repository at this point in the history
…38588)

* Fixed for Ability to create Container Registry with zone redundancy (issue#38488)
  • Loading branch information
v-hongli1 authored Feb 2, 2024
1 parent ad477de commit 922d0bb
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/resourcemanager/azure-resourcemanager-containerregistry",
"Tag": "java/resourcemanager/azure-resourcemanager-containerregistry_1a4bd3c103"
"Tag": "java/resourcemanager/azure-resourcemanager-containerregistry_c7a0288b18"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.azure.resourcemanager.containerregistry.models.SkuName;
import com.azure.resourcemanager.containerregistry.models.SourceUploadDefinition;
import com.azure.resourcemanager.containerregistry.models.WebhookOperations;
import com.azure.resourcemanager.containerregistry.models.ZoneRedundancy;
import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpoint;
import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpointConnection;
import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpointConnectionProvisioningState;
Expand Down Expand Up @@ -224,6 +225,11 @@ public boolean isDedicatedDataEndpointsEnabled() {
return ResourceManagerUtils.toPrimitiveBoolean(this.innerModel().dataEndpointEnabled());
}

@Override
public boolean isZoneRedundancyEnabled() {
return !Objects.isNull(this.innerModel().zoneRedundancy()) && ZoneRedundancy.ENABLED.equals(this.innerModel().zoneRedundancy());
}

@Override
public List<String> dedicatedDataEndpointsHostNames() {
return this.innerModel().dataEndpointHostNames() == null
Expand Down Expand Up @@ -453,6 +459,14 @@ public PagedFlux<PrivateLinkResource> listPrivateLinkResourcesAsync() {
.mapPage(PrivateLinkResourceImpl::new);
}

@Override
public RegistryImpl withZoneRedundancy() {
if (isInCreateMode()) {
this.innerModel().withZoneRedundancy(ZoneRedundancy.ENABLED);
}
return this;
}

private static final class PrivateLinkResourceImpl implements PrivateLinkResource {
private final PrivateLinkResourceInner innerModel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public interface Registry
/** @return whether the container registries dedicated data endpoints can be accessed from public network */
boolean isDedicatedDataEndpointsEnabled();

/** @return Whether or not zone redundancy is enabled for this container registry */
boolean isZoneRedundancyEnabled();

/** @return list of host names that will serve data when isDedicatedDataEndpointsEnabled is true */
List<String> dedicatedDataEndpointsHostNames();

Expand Down Expand Up @@ -239,6 +242,21 @@ interface WithDedicatedDataEndpoints {
WithCreate enableDedicatedDataEndpoints();
}

/**
* The stage of the container registry definition allowing to configure Zone Redundancy.
*/
interface WithZoneRedundancy {
/**
* Enables zone redundancy for the container registry.
*
* @return the next stage of the definition
* @see <a href="https://learn.microsoft.com/en-us/azure/container-registry/zone-redundancy">
* Enable zone redundancy
* </a>
*/
WithCreate withZoneRedundancy();
}

/**
* The stage of the definition which contains all the minimum required inputs for the resource to be created,
* but also allows for any other optional settings to be specified.
Expand All @@ -249,6 +267,7 @@ interface WithCreate
WithWebhook,
WithPublicNetworkAccess,
WithDedicatedDataEndpoints,
WithZoneRedundancy,
Resource.DefinitionWithTags<WithCreate> {
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.resourcemanager.containerregistry;

import com.azure.core.management.Region;
import com.azure.resourcemanager.containerregistry.models.Registry;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class RegistryOperationsTests extends RegistryTest {

@Override
protected void cleanUpResources() {
resourceManager.resourceGroups().beginDeleteByName(rgName);
}

@Test
public void canCreateContainerRegisterWithZoneRedundancy() {
final String acrName = generateRandomResourceName("acr", 10);
Registry registry =
registryManager
.containerRegistries()
.define(acrName)
.withRegion(Region.US_EAST)
.withNewResourceGroup(rgName)
.withPremiumSku()
.withRegistryNameAsAdminUser()
.withZoneRedundancy()
.create();
Assertions.assertTrue(registry.isZoneRedundancyEnabled());
}
}

0 comments on commit 922d0bb

Please sign in to comment.