Skip to content

Commit 160916d

Browse files
author
Siddharth Chatrola
committed
Code review comments fixed
1 parent d6bb282 commit 160916d

File tree

6 files changed

+46
-81
lines changed

6 files changed

+46
-81
lines changed

src/ResourceManager/RedisCache/Commands.RedisCache/Commands/NewAzureRedisCache.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ public class NewAzureRedisCache : RedisCacheCmdletBase
4545
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "Size of redis cache. Valid values: P1,P2, P3, P4, C0, C1, C2, C3, C4, C5, C6, 250MB, 1GB, 2.5GB, 6GB, 13GB, 26GB, 53GB")]
4646
[ValidateSet(SizeConverter.P1String, SizeConverter.P2String, SizeConverter.P3String, SizeConverter.P4String,
4747
SizeConverter.C0String, SizeConverter.C1String, SizeConverter.C2String, SizeConverter.C3String, SizeConverter.C4String, SizeConverter.C5String, SizeConverter.C6String,
48-
SizeConverter.C0, SizeConverter.C1, SizeConverter.C2, SizeConverter.C3P1, SizeConverter.C4P2, SizeConverter.C5P3, SizeConverter.C6P4, IgnoreCase = false)]
48+
SizeConverter.MB250, SizeConverter.GB1, SizeConverter.GB2_5, SizeConverter.GB6, SizeConverter.GB13, SizeConverter.GB26, SizeConverter.GB53, IgnoreCase = false)]
4949
public string Size { get; set; }
5050

51-
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "Wheather want to create Basic (1 Node), Standard (2 Node) or Premium cache.")]
51+
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "Choose to create a Basic, Standard, or Premium cache.")]
5252
[ValidateSet(SkuStrings.Basic, SkuStrings.Standard, SkuStrings.Premium, IgnoreCase = false)]
5353
public string Sku { get; set; }
5454

@@ -64,7 +64,7 @@ public class NewAzureRedisCache : RedisCacheCmdletBase
6464
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "A hash table which represents tenant settings.")]
6565
public Hashtable TenantSettings { get; set; }
6666

67-
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "The number of shards to be created on a Premium Cluster Cache.")]
67+
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "The number of shards to create on a Premium Cluster Cache.")]
6868
public int? ShardCount { get; set; }
6969

7070
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "The exact ARM resource ID of the virtual network to deploy the redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1")]

src/ResourceManager/RedisCache/Commands.RedisCache/Commands/SetAzureRedisCache.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public class SetAzureRedisCache : RedisCacheCmdletBase
3939
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "Size of redis cache. Valid values: P1,P2, P3, P4, C0, C1, C2, C3, C4, C5, C6, 250MB, 1GB, 2.5GB, 6GB, 13GB, 26GB, 53GB")]
4040
[ValidateSet(SizeConverter.P1String, SizeConverter.P2String, SizeConverter.P3String, SizeConverter.P4String,
4141
SizeConverter.C0String, SizeConverter.C1String, SizeConverter.C2String, SizeConverter.C3String, SizeConverter.C4String, SizeConverter.C5String, SizeConverter.C6String,
42-
SizeConverter.C0, SizeConverter.C1, SizeConverter.C2, SizeConverter.C3P1, SizeConverter.C4P2, SizeConverter.C5P3, SizeConverter.C6P4, IgnoreCase = false)]
42+
SizeConverter.MB250, SizeConverter.GB1, SizeConverter.GB2_5, SizeConverter.GB6, SizeConverter.GB13, SizeConverter.GB26, SizeConverter.GB53, IgnoreCase = false)]
4343
public string Size { get; set; }
4444

45-
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "Wheather want to create Basic (1 Node), Standard (2 Node) or Premium cache.")]
45+
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "Choose to create a Basic, Standard, or Premium cache.")]
4646
[ValidateSet(SkuStrings.Basic, SkuStrings.Standard, SkuStrings.Premium, IgnoreCase = false)]
4747
public string Sku { get; set; }
4848

@@ -58,7 +58,7 @@ public class SetAzureRedisCache : RedisCacheCmdletBase
5858
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "A hash table which represents tenant settings.")]
5959
public Hashtable TenantSettings { get; set; }
6060

61-
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "The number of shards to be created on a Premium Cluster Cache.")]
61+
[Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "The number of shards to create on a Premium Cluster Cache.")]
6262
public int? ShardCount { get; set; }
6363

6464
protected override void ProcessRecord()

src/ResourceManager/RedisCache/Commands.RedisCache/Models/RedisCacheAttributes.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ public RedisCacheAttributes(RedisResource cache, string resourceGroupName)
4040
Subnet = cache.Properties.Subnet;
4141
StaticIP = cache.Properties.StaticIP;
4242
TenantSettings = cache.Properties.TenantSettings;
43-
if (cache.Properties.ShardCount.HasValue)
44-
{
45-
ShardCount = cache.Properties.ShardCount.Value;
46-
}
43+
ShardCount = cache.Properties.ShardCount;
4744
}
4845

4946
public RedisCacheAttributes(RedisGetResponse cache, string resourceGroupName)

src/ResourceManager/RedisCache/Commands.RedisCache/Models/RedisCacheAttributesWithAccessKeys.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ public RedisCacheAttributesWithAccessKeys(RedisCreateOrUpdateResponse cache, str
4242
Subnet = cache.Resource.Properties.Subnet;
4343
StaticIP = cache.Resource.Properties.StaticIP;
4444
TenantSettings = cache.Resource.Properties.TenantSettings;
45-
if (cache.Resource.Properties.ShardCount.HasValue)
46-
{
47-
ShardCount = cache.Resource.Properties.ShardCount.Value;
48-
}
45+
ShardCount = cache.Resource.Properties.ShardCount;
4946
}
5047

5148
public string PrimaryKey { get; private set; }

src/ResourceManager/RedisCache/Commands.RedisCache/Models/RedisCacheClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ public RedisCreateOrUpdateResponse CreateOrUpdateCache(string resourceGroupName,
7676
parameters.Properties.ShardCount = shardCount.Value;
7777
}
7878

79-
if (!string.IsNullOrEmpty(virtualNetwork))
79+
if (!string.IsNullOrWhiteSpace(virtualNetwork))
8080
{
8181
parameters.Properties.VirtualNetwork = virtualNetwork;
8282
}
8383

84-
if (!string.IsNullOrEmpty(subnet))
84+
if (!string.IsNullOrWhiteSpace(subnet))
8585
{
8686
parameters.Properties.Subnet = subnet;
8787
}
8888

89-
if (!string.IsNullOrEmpty(staticIP))
89+
if (!string.IsNullOrWhiteSpace(staticIP))
9090
{
9191
parameters.Properties.StaticIP = staticIP;
9292
}

src/ResourceManager/RedisCache/Commands.RedisCache/Models/SizeConverter.cs

Lines changed: 35 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@
1414

1515
namespace Microsoft.Azure.Commands.RedisCache.Models
1616
{
17+
using System.Collections.Generic;
18+
1719
public static class SizeConverter
1820
{
19-
public const string C0 = "250MB";
20-
public const string C1 = "1GB";
21-
public const string C2 = "2.5GB";
22-
public const string C3P1 = "6GB";
23-
public const string C4P2 = "13GB";
24-
public const string C5P3 = "26GB";
25-
public const string C6P4 = "53GB";
21+
public const string MB250 = "250MB";
22+
public const string GB1 = "1GB";
23+
public const string GB2_5 = "2.5GB";
24+
public const string GB6 = "6GB";
25+
public const string GB13 = "13GB";
26+
public const string GB26 = "26GB";
27+
public const string GB53 = "53GB";
2628

2729
public const string C0String = "C0";
2830
public const string C1String = "C1";
@@ -36,19 +38,33 @@ public static class SizeConverter
3638
public const string P2String = "P2";
3739
public const string P3String = "P3";
3840
public const string P4String = "P4";
41+
42+
private static Dictionary<string, string> skuStringToAztualSize = new Dictionary<string, string>{
43+
{C0String,MB250},
44+
{C1String,GB1},
45+
{C2String,GB2_5},
46+
{C3String,GB6},
47+
{C4String,GB13},
48+
{C5String,GB26},
49+
{C6String,GB53},
50+
{P1String,GB6},
51+
{P2String,GB13},
52+
{P3String,GB26},
53+
{P4String,GB53}
54+
};
3955

4056
public static string GetSizeInRedisSpecificFormat(string actualSizeFromUser, bool isPremiumCache)
4157
{
4258
switch(actualSizeFromUser)
4359
{
4460
// accepting actual sizes
45-
case C0:
61+
case MB250:
4662
return C0String;
47-
case C1:
63+
case GB1:
4864
return C1String;
49-
case C2:
65+
case GB2_5:
5066
return C2String;
51-
case C3P1:
67+
case GB6:
5268
if(isPremiumCache)
5369
{
5470
return P1String;
@@ -57,7 +73,7 @@ public static string GetSizeInRedisSpecificFormat(string actualSizeFromUser, boo
5773
{
5874
return C3String;
5975
}
60-
case C4P2:
76+
case GB13:
6177
if(isPremiumCache)
6278
{
6379
return P2String;
@@ -66,7 +82,7 @@ public static string GetSizeInRedisSpecificFormat(string actualSizeFromUser, boo
6682
{
6783
return C4String;
6884
}
69-
case C5P3:
85+
case GB26:
7086
if (isPremiumCache)
7187
{
7288
return P3String;
@@ -75,7 +91,7 @@ public static string GetSizeInRedisSpecificFormat(string actualSizeFromUser, boo
7591
{
7692
return C5String;
7793
}
78-
case C6P4:
94+
case GB53:
7995
if (isPremiumCache)
8096
{
8197
return P4String;
@@ -85,64 +101,19 @@ public static string GetSizeInRedisSpecificFormat(string actualSizeFromUser, boo
85101
return C6String;
86102
}
87103
// accepting C0, C1 etc.
88-
case C0String:
89-
return C0String;
90-
case C1String:
91-
return C1String;
92-
case C2String:
93-
return C2String;
94-
case C3String:
95-
return C3String;
96-
case C4String:
97-
return C4String;
98-
case C5String:
99-
return C5String;
100-
case C6String:
101-
return C6String;
102-
case P1String:
103-
return P1String;
104-
case P2String:
105-
return P2String;
106-
case P3String:
107-
return P3String;
108-
case P4String:
109-
return P4String;
110104
default:
111-
return C1String;
105+
return actualSizeFromUser;
112106
}
113107
}
114108

115109
public static string GetSizeInUserSpecificFormat(string skuFamily, int skuCapacity)
116110
{
117111
string sizeConstant = skuFamily + skuCapacity.ToString();
118-
switch (sizeConstant)
119-
{
120-
// accepting C0, C1 etc.
121-
case C0String:
122-
return C0;
123-
case C1String:
124-
return C1;
125-
case C2String:
126-
return C2;
127-
case C3String:
128-
return C3P1;
129-
case C4String:
130-
return C4P2;
131-
case C5String:
132-
return C5P3;
133-
case C6String:
134-
return C6P4;
135-
case P1String:
136-
return C3P1;
137-
case P2String:
138-
return C4P2;
139-
case P3String:
140-
return C5P3;
141-
case P4String:
142-
return C6P4;
143-
default:
144-
return C1;
112+
if (skuStringToAztualSize.ContainsKey(sizeConstant))
113+
{
114+
return skuStringToAztualSize[sizeConstant];
145115
}
116+
return GB1;
146117
}
147118
}
148119
}

0 commit comments

Comments
 (0)