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

Fixed for Ability to create Container Registry with zone redundancy #38588

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fixed for Ability to create Container Registry with zone redundancy (…
…issue#38488)
  • Loading branch information
v-hongli1 committed Feb 2, 2024
commit 78be46d23e3283e63fee1c45149c520ff722c02d
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 ZoneRedundancy zoneRedundancy() {
return 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 */
ZoneRedundancy zoneRedundancy();

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

Expand Down Expand Up @@ -239,6 +242,18 @@ 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
*/
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 +264,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,34 @@
// 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 com.azure.resourcemanager.containerregistry.models.ZoneRedundancy;
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.assertEquals(ZoneRedundancy.ENABLED, registry.zoneRedundancy());
}
}
Loading