Skip to content

Commit b7e182f

Browse files
[ContainerInstance] Add backward compatibility for property renaming (Azure#33771)
1 parent ad17455 commit b7e182f

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

sdk/containerinstance/Azure.ResourceManager.ContainerInstance/CHANGELOG.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# Release History
22

3-
## 1.1.0-beta.2 (Unreleased)
4-
5-
### Features Added
6-
7-
### Breaking Changes
8-
9-
### Bugs Fixed
3+
## 1.1.0-beta.2 (2023-02-01)
104

115
### Other Changes
126

7+
- Added backward compatibility for the change of `DnsNameLabelReusePolicy` property replaced by `AutoGeneratedDnsNameLabelScope` in `ContainerGroupIPAddress`.
8+
139
## 1.1.0-beta.1 (2023-01-26)
1410
This release is a preview release for ContainerGroup Priority property and Confidential Containers.
1511

sdk/containerinstance/Azure.ResourceManager.ContainerInstance/api/Azure.ResourceManager.ContainerInstance.netstandard2.0.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public ContainerGroupIPAddress(System.Collections.Generic.IEnumerable<Azure.Reso
235235
public Azure.ResourceManager.ContainerInstance.Models.DnsNameLabelReusePolicy? AutoGeneratedDomainNameLabelScope { get { throw null; } set { } }
236236
public string DnsNameLabel { get { throw null; } set { } }
237237
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
238-
[System.ObsoleteAttribute("DnsNameLabelReusePolicy is deprecated, use AutoGeneratedDnsNameLabelScope instead")]
238+
[System.ObsoleteAttribute("DnsNameLabelReusePolicy is deprecated, use AutoGeneratedDnsNameLabelScope instead", false)]
239239
public Azure.ResourceManager.ContainerInstance.Models.AutoGeneratedDomainNameLabelScope? DnsNameLabelReusePolicy { get { throw null; } set { } }
240240
public string Fqdn { get { throw null; } }
241241
public System.Net.IPAddress IP { get { throw null; } set { } }

sdk/containerinstance/Azure.ResourceManager.ContainerInstance/src/Customized/Models/ContainerGroupIPAddress.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@
44
#nullable disable
55

66
using System;
7-
using System.Collections.Generic;
8-
using System.Linq;
9-
using System.Net;
107
using System.ComponentModel;
11-
using Azure.Core;
128

139
namespace Azure.ResourceManager.ContainerInstance.Models
1410
{
1511
/// <summary> IP address for the container group. </summary>
1612
public partial class ContainerGroupIPAddress
1713
{
1814
/// <summary> The value representing the security enum. </summary>
19-
[Obsolete("DnsNameLabelReusePolicy is deprecated, use AutoGeneratedDnsNameLabelScope instead")]
15+
[Obsolete("DnsNameLabelReusePolicy is deprecated, use AutoGeneratedDnsNameLabelScope instead", false)]
2016
[EditorBrowsable(EditorBrowsableState.Never)]
21-
public AutoGeneratedDomainNameLabelScope? DnsNameLabelReusePolicy { get; set; }
17+
public AutoGeneratedDomainNameLabelScope? DnsNameLabelReusePolicy
18+
{
19+
get => AutoGeneratedDomainNameLabelScope == null ? null : new AutoGeneratedDomainNameLabelScope(AutoGeneratedDomainNameLabelScope.Value.ToString());
20+
set
21+
{
22+
AutoGeneratedDomainNameLabelScope = value == null ? null : new DnsNameLabelReusePolicy(value.Value.ToString());
23+
}
24+
}
2225
}
2326
}

sdk/containerinstance/Azure.ResourceManager.ContainerInstance/tests/ContainerInstanceManagementTestBase.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ protected static ContainerGroupData CreateContainerGroupData(string containerGro
9898
keyName: "testencryptionkey",
9999
keyVersion: "804d3f1d5ce2456b9bc3dc9e35aaa67e");
100100

101-
if (priority == "Spot") {
101+
if (priority == "Spot")
102+
{
102103
var priorityContainerGroup = new ContainerGroupData(
103104
location: "westus",
104105
containers: containers,
@@ -125,10 +126,10 @@ protected static ContainerGroupData CreateContainerGroupData(string containerGro
125126
},
126127
EncryptionProperties = encryptionProps,
127128
Priority = ContainerGroupPriority.Spot,
128-
Sku = ContainerGroupSku.Standard
129+
Sku = ContainerGroupSku.Standard
129130
};
130131
return priorityContainerGroup;
131-
}
132+
}
132133

133134
var confidentialComputeProperties = new ConfidentialComputeProperties();
134135
var sku = new ContainerGroupSku("Standard");
@@ -145,7 +146,7 @@ protected static ContainerGroupData CreateContainerGroupData(string containerGro
145146
cpu: 1.0))
146147
)
147148
{
148-
Ports =
149+
Ports =
149150
{
150151
new ContainerPort(80)
151152
},
@@ -171,7 +172,7 @@ protected static ContainerGroupData CreateContainerGroupData(string containerGro
171172
IPAddress = new ContainerGroupIPAddress(
172173
ports: new[] { new ContainerGroupPort(80) { Protocol = ContainerGroupNetworkProtocol.Tcp } },
173174
addressType: ContainerGroupIPAddressType.Public
174-
),
175+
),
175176
RestartPolicy = ContainerGroupRestartPolicy.Never,
176177
Identity = new ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssigned),
177178
InitContainers = {
@@ -194,7 +195,7 @@ protected static ContainerGroupData CreateContainerGroupData(string containerGro
194195
Sku = ContainerGroupSku.Confidential
195196
};
196197
return confContainerGroup;
197-
}
198+
}
198199

199200
var containerGroup = new ContainerGroupData(
200201
location: "westus",
@@ -249,11 +250,11 @@ protected void VerifyContainerGroupProperties(ContainerGroupData expected, Conta
249250
Assert.AreEqual(expected.Diagnostics?.LogAnalytics.WorkspaceId, actual.Diagnostics?.LogAnalytics.WorkspaceId);
250251
Assert.NotNull(actual.Containers);
251252
Assert.AreEqual(1, actual.Containers.Count);
252-
if (expected.Priority != ContainerGroupPriority.Spot)
253-
{
254-
Assert.NotNull(actual.IPAddress);
253+
if (expected.Priority != ContainerGroupPriority.Spot)
254+
{
255+
Assert.NotNull(actual.IPAddress);
255256
Assert.NotNull(actual.IPAddress.IP);
256-
}
257+
}
257258
Assert.AreEqual(expected.EncryptionProperties?.KeyName, actual.EncryptionProperties?.KeyName);
258259
Assert.AreEqual(expected.EncryptionProperties?.KeyVersion, actual.EncryptionProperties?.KeyVersion);
259260
Assert.AreEqual(expected.EncryptionProperties?.VaultBaseUri, actual.EncryptionProperties?.VaultBaseUri);
@@ -267,9 +268,10 @@ protected void VerifyContainerGroupProperties(ContainerGroupData expected, Conta
267268
Assert.AreEqual(expected.InitContainers[0].Name, actual.InitContainers[0].Name);
268269
Assert.AreEqual(expected.InitContainers[0].Image, actual.InitContainers[0].Image);
269270
Assert.AreEqual(expected.Priority, actual.Priority);
270-
if (expected.Sku == ContainerGroupSku.Confidential) {
271+
if (expected.Sku == ContainerGroupSku.Confidential)
272+
{
271273
Assert.NotNull(actual.ConfidentialComputeProperties?.CcePolicy);
272-
}
274+
}
273275
}
274276
}
275277
}

0 commit comments

Comments
 (0)