This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 522
/
images.go
67 lines (60 loc) · 2.56 KB
/
images.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package engine
import (
"fmt"
"github.com/Azure/aks-engine/pkg/api"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
"github.com/Azure/go-autorest/autorest/to"
)
func createWindowsImageReference(agentPoolProfileName string, windowsProfile *api.WindowsProfile) *compute.ImageReference {
var computeImageRef compute.ImageReference
if windowsProfile.HasCustomImage() {
computeImageRef = compute.ImageReference{
ID: to.StringPtr(fmt.Sprintf("[resourceId('Microsoft.Compute/images', '%sCustomWindowsImage')]", agentPoolProfileName)),
}
} else if windowsProfile.HasImageRef() {
imageRef := windowsProfile.ImageRef
if windowsProfile.HasImageGallery() {
computeImageRef = compute.ImageReference{
ID: to.StringPtr(fmt.Sprintf("[concat('/subscriptions/', '%s', '/resourceGroups/', parameters('agentWindowsImageResourceGroup'), '/providers/Microsoft.Compute/galleries/', '%s', '/images/', parameters('agentWindowsImageName'), '/versions/', '%s')]", imageRef.SubscriptionID, imageRef.Gallery, imageRef.Version)),
}
} else {
computeImageRef = compute.ImageReference{
ID: to.StringPtr("[resourceId(parameters('agentWindowsImageResourceGroup'), 'Microsoft.Compute/images', parameters('agentWindowsImageName'))]"),
}
}
} else {
computeImageRef = compute.ImageReference{
Offer: to.StringPtr("[parameters('agentWindowsOffer')]"),
Publisher: to.StringPtr("[parameters('agentWindowsPublisher')]"),
Sku: to.StringPtr("[parameters('agentWindowsSku')]"),
Version: to.StringPtr("[parameters('agentWindowsVersion')]"),
}
}
return &computeImageRef
}
func createWindowsImage(profile *api.AgentPoolProfile) ImageARM {
return ImageARM{
ARMResource: ARMResource{
APIVersion: "[variables('apiVersionCompute')]",
},
Image: compute.Image{
Type: to.StringPtr("Microsoft.Compute/images"),
Name: to.StringPtr(fmt.Sprintf("%sCustomWindowsImage", profile.Name)),
Location: to.StringPtr("[variables('location')]"),
ImageProperties: &compute.ImageProperties{
StorageProfile: &compute.ImageStorageProfile{
OsDisk: &compute.ImageOSDisk{
OsType: "Windows",
OsState: compute.Generalized,
BlobURI: to.StringPtr("[parameters('agentWindowsSourceUrl')]"),
StorageAccountType: compute.StorageAccountTypesStandardLRS,
},
},
// TODO: Expose Hyper-V generation for VHD URL refs in apimodel
HyperVGeneration: compute.HyperVGenerationTypesV1,
},
},
}
}