Skip to content

Commit eaeff5c

Browse files
chore(deps): added base_image_publisher and base_image_offer fields for windows_settings.json (#7998)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> former name: chore(deps): add publisherID and offerID to WS2022 config for new image
1 parent 810b5a7 commit eaeff5c

File tree

5 files changed

+100
-7
lines changed

5 files changed

+100
-7
lines changed

schemas/windows_settings.cue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
#WindowsPatches: [...#WindowsPatch]
2020

2121
#WindowsBaseVersion: {
22-
comment?: string
23-
os_disk_size: string
24-
base_image_sku: string,
25-
base_image_version: string
26-
windows_image_name: string
27-
patches_to_apply: #WindowsPatches
22+
comment?: string
23+
os_disk_size: string
24+
base_image_publisher?: string
25+
base_image_offer?: string
26+
base_image_sku: string
27+
base_image_version: string
28+
windows_image_name: string
29+
patches_to_apply: #WindowsPatches
2830
}
2931

3032
#WindowsComments: [...string]

vhdbuilder/packer/produce-packer-settings-functions.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,20 @@ function prepare_windows_vhd() {
268268
WINDOWS_IMAGE_VERSION=$(jq -r ".WindowsBaseVersions.\"${WINDOWS_SKU}\".base_image_version" <$CDIR/windows/windows_settings.json)
269269
WINDOWS_IMAGE_NAME=$(jq -r ".WindowsBaseVersions.\"${WINDOWS_SKU}\".windows_image_name" <$CDIR/windows/windows_settings.json)
270270
OS_DISK_SIZE=$(jq -r ".WindowsBaseVersions.\"${WINDOWS_SKU}\".os_disk_size" <$CDIR/windows/windows_settings.json)
271+
272+
local sku_publisher
273+
if sku_publisher=$(jq -re ".WindowsBaseVersions.\"${WINDOWS_SKU}\".base_image_publisher" <$CDIR/windows/windows_settings.json); then
274+
if [ -n "${sku_publisher}" ] && [ "${sku_publisher}" != "null" ]; then
275+
WINDOWS_IMAGE_PUBLISHER="${sku_publisher}"
276+
fi
277+
fi
278+
local sku_offer
279+
if sku_offer=$(jq -re ".WindowsBaseVersions.\"${WINDOWS_SKU}\".base_image_offer" <$CDIR/windows/windows_settings.json); then
280+
if [ -n "${sku_offer}" ] && [ "${sku_offer}" != "null" ]; then
281+
WINDOWS_IMAGE_OFFER="${sku_offer}"
282+
fi
283+
fi
284+
271285
if [ "null" != "${OS_DISK_SIZE}" ]; then
272286
echo "Setting os_disk_size_gb to the value in windows-settings.json for ${WINDOWS_SKU}: ${OS_DISK_SIZE}"
273287
os_disk_size_gb=${OS_DISK_SIZE}
@@ -278,6 +292,8 @@ function prepare_windows_vhd() {
278292
imported_windows_image_name="${WINDOWS_IMAGE_NAME}-imported-${CREATE_TIME}-${RANDOM}"
279293

280294
echo "Got base image data: "
295+
echo " WINDOWS_IMAGE_PUBLISHER: ${WINDOWS_IMAGE_PUBLISHER}"
296+
echo " WINDOWS_IMAGE_OFFER: ${WINDOWS_IMAGE_OFFER}"
281297
echo " WINDOWS_IMAGE_SKU: ${WINDOWS_IMAGE_SKU}"
282298
echo " WINDOWS_IMAGE_VERSION: ${WINDOWS_IMAGE_VERSION}"
283299
echo " WINDOWS_IMAGE_NAME: ${WINDOWS_IMAGE_NAME}"

vhdbuilder/packer/windows/components_json_helpers.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,27 @@ function GetAllCachedThings {
391391
$ociArtifacts = GetOCIArtifactsFromComponentsJson $componentsJsonContent
392392
$regKeys = GetRegKeysToApply $windowsSettingsContent
393393
$baseVersion = GetWindowsBaseVersion -windowsSku $windowsSku -windowsSettingsContent $windowsSettingsContent
394+
$baseVersionBlock = $windowsSettingsContent.WindowsBaseVersions."$windowsSku"
394395

395396
$items += "Windows ${windowsSku} base version: ${baseVersion}"
397+
if ($baseVersionBlock -ne $null) {
398+
$items += "Windows ${windowsSku} base image sku: $($baseVersionBlock.base_image_sku)"
399+
$items += "Windows ${windowsSku} os disk size: $($baseVersionBlock.os_disk_size)"
400+
401+
if (-not [string]::IsNullOrEmpty($baseVersionBlock.base_image_publisher)) {
402+
$items += "Windows ${windowsSku} base image publisher: $($baseVersionBlock.base_image_publisher)"
403+
}
404+
if (-not [string]::IsNullOrEmpty($baseVersionBlock.base_image_offer)) {
405+
$items += "Windows ${windowsSku} base image offer: $($baseVersionBlock.base_image_offer)"
406+
}
407+
}
408+
409+
$patchInfo = GetPatchInfo -windowsSku $windowsSku -windowsSettingsContent $windowsSettingsContent
410+
if ($patchInfo -ne $null -and $patchInfo.Count -gt 0) {
411+
foreach ($patch in $patchInfo) {
412+
$items += "Windows ${windowsSku} patch: $($patch.id) $($patch.url)"
413+
}
414+
}
396415

397416
foreach ($packageName in $packages.keys) {
398417
foreach ($package in $packages[$packageName]) {

vhdbuilder/packer/windows/components_json_helpers.tests.ps1

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ Describe 'Tests of GetAllCachedThings ' {
3838
$windowsSettingsTestString = '{
3939
"WindowsBaseVersions": {
4040
"2019": {
41+
"os_disk_size": "35",
42+
"base_image_publisher": "MicrosoftWindowsServer",
43+
"base_image_offer": "WindowsServer",
4144
"base_image_sku": "2019-Datacenter-Core-smalldisk",
4245
"windows_image_name": "windows-2019",
4346
"base_image_version": "17763.6893.250210",
4447
"patches_to_apply": [{"id": "patchid", "url": "patch_url"}]
4548
},
4649
"23H2-gen2": {
50+
"os_disk_size": "40",
4751
"base_image_sku": "2019-Datacenter-Core-smalldisk",
4852
"windows_image_name": "windows-2019",
4953
"base_image_version": "17763.6893.250210",
@@ -161,6 +165,54 @@ Describe 'Tests of GetAllCachedThings ' {
161165

162166
$allpackages | Should -Be ( $allpackages | Sort-Object )
163167
}
168+
169+
it 'has the base image sku in it' {
170+
$windowsSku = "2019"
171+
172+
$allpackages = GetAllCachedThings $componentsJson $windowsSettings
173+
174+
$allpackages | Should -Contain "Windows 2019 base image sku: 2019-Datacenter-Core-smalldisk"
175+
}
176+
177+
it 'has the os disk size in it' {
178+
$windowsSku = "2019"
179+
180+
$allpackages = GetAllCachedThings $componentsJson $windowsSettings
181+
182+
$allpackages | Should -Contain "Windows 2019 os disk size: 35"
183+
}
184+
185+
it 'has the base image publisher when set' {
186+
$windowsSku = "2019"
187+
188+
$allpackages = GetAllCachedThings $componentsJson $windowsSettings
189+
190+
$allpackages | Should -Contain "Windows 2019 base image publisher: MicrosoftWindowsServer"
191+
}
192+
193+
it 'has the base image offer when set' {
194+
$windowsSku = "2019"
195+
196+
$allpackages = GetAllCachedThings $componentsJson $windowsSettings
197+
198+
$allpackages | Should -Contain "Windows 2019 base image offer: WindowsServer"
199+
}
200+
201+
it 'does not have base image publisher when not set' {
202+
$windowsSku = "23H2-gen2"
203+
204+
$allpackages = GetAllCachedThings $componentsJson $windowsSettings
205+
206+
($allpackages | Where-Object { $_ -like "Windows 23H2-gen2 base image publisher:*" }) | Should -BeNullOrEmpty
207+
}
208+
209+
it 'does not have base image offer when not set' {
210+
$windowsSku = "23H2-gen2"
211+
212+
$allpackages = GetAllCachedThings $componentsJson $windowsSettings
213+
214+
($allpackages | Where-Object { $_ -like "Windows 23H2-gen2 base image offer:*" }) | Should -BeNullOrEmpty
215+
}
164216
}
165217

166218

vhdbuilder/packer/windows/windows_settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
"WindowsBaseVersions": {
1616
"2022-containerd": {
1717
"os_disk_size": "35",
18+
"base_image_publisher": "MicrosoftWindowsServer",
19+
"base_image_offer": "windowsserver2022",
1820
"base_image_sku": "2022-Datacenter-Core-smalldisk",
1921
"windows_image_name": "windows-2022-containerd",
2022
"base_image_version": "20348.4893.260303",
2123
"patches_to_apply": []
2224
},
2325
"2022-containerd-gen2": {
2426
"os_disk_size": "35",
27+
"base_image_publisher": "MicrosoftWindowsServer",
28+
"base_image_offer": "windowsserver2022",
2529
"base_image_sku": "2022-datacenter-core-smalldisk-g2",
2630
"windows_image_name": "windows-2022-containerd",
2731
"base_image_version": "20348.4893.260303",
@@ -746,4 +750,4 @@
746750
"Type": "DWORD"
747751
}
748752
]
749-
}
753+
}

0 commit comments

Comments
 (0)