@@ -80,7 +80,7 @@ public class SetAzureVMChefExtensionCommand : VirtualMachineChefExtensionCmdletB
80
80
ValueFromPipelineByPropertyName = true ,
81
81
HelpMessage = "Flag to opt for auto chef-client update. Chef-client update is false by default." ) ]
82
82
[ ValidateNotNullOrEmpty ]
83
- public SwitchParameter AutoUpdateClient { get ; set ; }
83
+ public SwitchParameter AutoUpdateChefClient { get ; set ; }
84
84
85
85
[ Parameter (
86
86
Mandatory = true ,
@@ -108,9 +108,12 @@ internal void ExecuteCommand()
108
108
private string GetLatestChefExtensionVersion ( )
109
109
{
110
110
var extensionList = this . ComputeClient . VirtualMachineExtensions . List ( ) ;
111
- return extensionList . ResourceExtensions . Where (
111
+ var version = extensionList . ResourceExtensions . Where (
112
112
extension => extension . Publisher == ExtensionDefaultPublisher
113
113
&& extension . Name == base . extensionName ) . Max ( extension => extension . Version ) ;
114
+ string [ ] separators = { "." } ;
115
+ string majorVersion = version . Split ( separators , StringSplitOptions . None ) [ 0 ] ;
116
+ return majorVersion + ".*" ;
114
117
}
115
118
116
119
private void SetDefault ( )
@@ -147,7 +150,7 @@ private void SetPublicConfig()
147
150
bool IsChefServerUrlEmpty = string . IsNullOrEmpty ( this . ChefServerUrl ) ;
148
151
bool IsValidationClientNameEmpty = string . IsNullOrEmpty ( this . ValidationClientName ) ;
149
152
bool IsRunListEmpty = string . IsNullOrEmpty ( this . RunList ) ;
150
- string AutoUpdateClient = this . AutoUpdateClient . IsPresent ? "true" : "false" ;
153
+ string AutoUpdateChefClient = this . AutoUpdateChefClient . IsPresent ? "true" : "false" ;
151
154
152
155
//Cases handled:
153
156
// 1. When clientRb given by user and:
@@ -200,13 +203,13 @@ private void SetPublicConfig()
200
203
if ( IsRunListEmpty )
201
204
{
202
205
this . PublicConfiguration = string . Format ( "{{{0},{1}}}" ,
203
- string . Format ( AutoUpdateTemplate , AutoUpdateClient ) ,
206
+ string . Format ( AutoUpdateTemplate , AutoUpdateChefClient ) ,
204
207
string . Format ( ClientRbTemplate , ClientConfig ) ) ;
205
208
}
206
209
else
207
210
{
208
211
this . PublicConfiguration = string . Format ( "{{{0},{1},{2}}}" ,
209
- string . Format ( AutoUpdateTemplate , AutoUpdateClient ) ,
212
+ string . Format ( AutoUpdateTemplate , AutoUpdateChefClient ) ,
210
213
string . Format ( ClientRbTemplate , ClientConfig ) ,
211
214
string . Format ( RunListTemplate , this . RunList ) ) ;
212
215
}
0 commit comments