Skip to content

Commit 117f1cb

Browse files
address comments.
1 parent 86878c3 commit 117f1cb

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

src/ResourceManager/Compute/Commands.Compute/Properties/Resources.Designer.cs

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/Compute/Commands.Compute/Properties/Resources.resx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,4 +583,15 @@ The file needs to be a PowerShell script (.ps1 or .psm1) or a ZIP archive (.zip)
583583
<value>Use '{0}' to connect to the VMSS instances.</value>
584584
<comment>{0} = connection string</comment>
585585
</data>
586+
<data name="ComputeInvalidImageName" xml:space="preserve">
587+
<value>Invalid image resource id '{0}'.</value>
588+
<comment>{0} = image resource id</comment>
589+
</data>
590+
<data name="ComputeMismatchSubscription" xml:space="preserve">
591+
<value>The image subscription doesn't match the current subscription.</value>
592+
</data>
593+
<data name="ComputeNoImageFound" xml:space="preserve">
594+
<value>Can't find the image '{0}'.</value>
595+
<comment>{0} = image name</comment>
596+
</data>
586597
</root>

src/ResourceManager/Compute/Commands.Compute/Strategies/ComputeRp/ImageEx.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ public static async Task<ImageAndOsType> UpdateImageAndOsTypeAsync(
8484
location, image.Publisher, image.Offer, image.Sku, image.Version);
8585
return new ImageAndOsType(imageModel.OsDiskImage.OperatingSystem, image);
8686
}
87-
if (imageName.Contains("/"))
87+
else if (imageName.Contains("/"))
8888
{
8989
var imageArray = imageName.Split('/');
9090
if (imageArray.Length != 9)
9191
{
92-
throw new ArgumentException("Invalid image resource id '" + imageName + "'.");
92+
throw new ArgumentException(string.Format(Resources.ComputeInvalidImageName, imageName));
9393
}
9494
// has to be ""
9595
var empty = imageArray[0];
@@ -114,12 +114,12 @@ public static async Task<ImageAndOsType> UpdateImageAndOsTypeAsync(
114114
|| providerNamespace != ComputeStrategy.Namespace
115115
|| provider != "images")
116116
{
117-
throw new ArgumentException("Invalid image resource id '" + imageName + "'.");
117+
throw new ArgumentException(string.Format(Resources.ComputeInvalidImageName, imageName));
118118
}
119119

120120
if (compute.SubscriptionId != subscriptionId)
121121
{
122-
throw new ArgumentException("The image subscription doesn't match the current subscription.");
122+
throw new ArgumentException(Resources.ComputeMismatchSubscription);
123123
}
124124

125125
var localImage = await compute.Images.GetAsync(imageResourceGroupName, resourceName);
@@ -156,8 +156,7 @@ public static async Task<ImageAndOsType> UpdateImageAndOsTypeAsync(
156156

157157
if (result == null)
158158
{
159-
// TODO: move it to resource.
160-
throw new ArgumentException("Can't find the image '" + imageName + "'");
159+
throw new ArgumentException(string.Format(Resources.ComputeNoImageFound, imageName));
161160
}
162161

163162
return result;

0 commit comments

Comments
 (0)