Skip to content

Commit 016d848

Browse files
committed
Merge pull request #57 from ClogenyTechnologies/sid-fix-chef-extension-version
Chef Extension default version should be Major.*
2 parents 928c243 + b739664 commit 016d848

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/Chef/SetAzureVMChefExtension.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public class SetAzureVMChefExtensionCommand : VirtualMachineChefExtensionCmdletB
8080
ValueFromPipelineByPropertyName = true,
8181
HelpMessage = "Flag to opt for auto chef-client update. Chef-client update is false by default.")]
8282
[ValidateNotNullOrEmpty]
83-
public SwitchParameter AutoUpdateClient { get; set; }
83+
public SwitchParameter AutoUpdateChefClient { get; set; }
8484

8585
[Parameter(
8686
Mandatory = true,
@@ -108,9 +108,12 @@ internal void ExecuteCommand()
108108
private string GetLatestChefExtensionVersion()
109109
{
110110
var extensionList = this.ComputeClient.VirtualMachineExtensions.List();
111-
return extensionList.ResourceExtensions.Where(
111+
var version = extensionList.ResourceExtensions.Where(
112112
extension => extension.Publisher == ExtensionDefaultPublisher
113113
&& extension.Name == base.extensionName).Max(extension => extension.Version);
114+
string[] separators = {"."};
115+
string majorVersion = version.Split(separators, StringSplitOptions.None)[0];
116+
return majorVersion + ".*";
114117
}
115118

116119
private void SetDefault()
@@ -147,7 +150,7 @@ private void SetPublicConfig()
147150
bool IsChefServerUrlEmpty = string.IsNullOrEmpty(this.ChefServerUrl);
148151
bool IsValidationClientNameEmpty = string.IsNullOrEmpty(this.ValidationClientName);
149152
bool IsRunListEmpty = string.IsNullOrEmpty(this.RunList);
150-
string AutoUpdateClient = this.AutoUpdateClient.IsPresent ? "true" : "false";
153+
string AutoUpdateChefClient = this.AutoUpdateChefClient.IsPresent ? "true" : "false";
151154

152155
//Cases handled:
153156
// 1. When clientRb given by user and:
@@ -200,13 +203,13 @@ private void SetPublicConfig()
200203
if (IsRunListEmpty)
201204
{
202205
this.PublicConfiguration = string.Format("{{{0},{1}}}",
203-
string.Format(AutoUpdateTemplate, AutoUpdateClient),
206+
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
204207
string.Format(ClientRbTemplate, ClientConfig));
205208
}
206209
else
207210
{
208211
this.PublicConfiguration = string.Format("{{{0},{1},{2}}}",
209-
string.Format(AutoUpdateTemplate, AutoUpdateClient),
212+
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
210213
string.Format(ClientRbTemplate, ClientConfig),
211214
string.Format(RunListTemplate, this.RunList));
212215
}

src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.dll-Help.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32702,7 +32702,7 @@ PS C:\> Get-AzureVM -ServiceName "ContosoService03" -Name "Con
3270232702
<dev:defaultValue></dev:defaultValue>
3270332703
</command:parameter>
3270432704
<command:parameter required="false" variableLength="false" globbing="false" position="named">
32705-
<maml:name>AutoUpdateClient</maml:name>
32705+
<maml:name>AutoUpdateChefClient</maml:name>
3270632706
<maml:description>
3270732707
<maml:para>Flag to opt for auto chef-client update. Chef-client update is false by default.</maml:para>
3270832708
</maml:description>

0 commit comments

Comments
 (0)