Skip to content

Commit

Permalink
feat: change windows profile defaults for Azure Stack (#1592)
Browse files Browse the repository at this point in the history
  • Loading branch information
chappleg authored and acs-bot committed Jul 8, 2019
1 parent 19405cf commit 8a78abb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 8 deletions.
9 changes: 9 additions & 0 deletions pkg/api/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ const (

// MaxAzureStackManagedDiskSize = size for Kubernetes master etcd disk volumes in GB if > 10 nodes as this is max what Azure Stack supports today.
MaxAzureStackManagedDiskSize = "1023"

// DefaultAzureStackWindowsOffer sets the default WindowsOffer value in WindowsProfile for Azure Stack
DefaultAzureStackWindowsOffer = "WindowsServer"

// DefaultAzureStackWindowsSku sets the default WindowsSku value in WindowsProfile for Azure Stack
DefaultAzureStackWindowsSku = "2019-Datacenter-Core-with-Containers"

// DefaultAzureStackImageVersion sets the default ImageVersion value in WindowsProfile for Azure Stack
DefaultAzureStackImageVersion = "latest"
)

// WindowsProfile defaults
Expand Down
29 changes: 21 additions & 8 deletions pkg/api/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,14 +670,27 @@ func (p *Properties) setWindowsProfileDefaults(isUpgrade, isScale bool) {
if windowsProfile.WindowsPublisher == "" {
windowsProfile.WindowsPublisher = DefaultWindowsPublisher
}
if windowsProfile.WindowsOffer == "" {
windowsProfile.WindowsOffer = DefaultWindowsOffer
}
if windowsProfile.WindowsSku == "" {
windowsProfile.WindowsSku = DefaultWindowsSku
}
if windowsProfile.ImageVersion == "" {
windowsProfile.ImageVersion = DefaultImageVersion

if p.IsAzureStackCloud() {
if windowsProfile.WindowsOffer == "" {
windowsProfile.WindowsOffer = DefaultAzureStackWindowsOffer
}
if windowsProfile.WindowsSku == "" {
windowsProfile.WindowsSku = DefaultAzureStackWindowsSku
}
if windowsProfile.ImageVersion == "" {
windowsProfile.ImageVersion = DefaultAzureStackImageVersion
}
} else {
if windowsProfile.WindowsOffer == "" {
windowsProfile.WindowsOffer = DefaultWindowsOffer
}
if windowsProfile.WindowsSku == "" {
windowsProfile.WindowsSku = DefaultWindowsSku
}
if windowsProfile.ImageVersion == "" {
windowsProfile.ImageVersion = DefaultImageVersion
}
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions pkg/api/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,7 @@ func TestWindowsProfileDefaults(t *testing.T) {
name string // test case name
windowsProfile WindowsProfile
expectedWindowsProfile WindowsProfile
isAzureStack bool
}{
{
"defaults",
Expand All @@ -1508,6 +1509,7 @@ func TestWindowsProfileDefaults(t *testing.T) {
WindowsDockerVersion: "",
SSHEnabled: false,
},
false,
},
{
"user overrides",
Expand All @@ -1528,12 +1530,32 @@ func TestWindowsProfileDefaults(t *testing.T) {
WindowsDockerVersion: "",
SSHEnabled: false,
},
false,
},
{
"Azure Stack defaults",
WindowsProfile{},
WindowsProfile{
WindowsPublisher: DefaultWindowsPublisher,
WindowsOffer: DefaultAzureStackWindowsOffer,
WindowsSku: DefaultAzureStackWindowsSku,
ImageVersion: DefaultAzureStackImageVersion,
AdminUsername: "",
AdminPassword: "",
WindowsImageSourceURL: "",
WindowsDockerVersion: "",
SSHEnabled: false,
},
true,
},
}

for _, test := range tests {
mockAPI := getMockAPIProperties("1.14.0")
mockAPI.WindowsProfile = &test.windowsProfile
if test.isAzureStack {
mockAPI.CustomCloudProfile = &CustomCloudProfile{}
}
mockAPI.setWindowsProfileDefaults(false, false)
if mockAPI.WindowsProfile.WindowsPublisher != test.expectedWindowsProfile.WindowsPublisher {
t.Fatalf("setWindowsProfileDefaults() test case %v did not return right default values %v != %v", test.name, mockAPI.WindowsProfile.WindowsPublisher, test.expectedWindowsProfile.WindowsPublisher)
Expand Down

0 comments on commit 8a78abb

Please sign in to comment.