azure: Handle SDK changes

There are two types for storage profile, but they use the same
serialization name (storageProfile).  This creates problems, so I worked
around it by taking the union of this type as well as OS Disk.
pull/4943/head
Christopher Boumenot 9 years ago
parent 123c45caca
commit 9425ece680

@ -144,7 +144,6 @@
"storageProfile": {
"osDisk": {
"blobUri": "",
"osState": "",
"osType": "Linux"
}
}

@ -35,6 +35,24 @@ type Resource struct {
Resources *[]Resource `json:"resources,omitempty"`
}
type OSDiskUnion struct {
OsType compute.OperatingSystemTypes `json:"osType,omitempty"`
OsState compute.OperatingSystemStateTypes `json:"osState,omitempty"`
BlobURI *string `json:"blobUri,omitempty"`
Name *string `json:"name,omitempty"`
Vhd *compute.VirtualHardDisk `json:"vhd,omitempty"`
Image *compute.VirtualHardDisk `json:"image,omitempty"`
Caching compute.CachingTypes `json:"caching,omitempty"`
CreateOption compute.DiskCreateOptionTypes `json:"createOption,omitempty"`
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
}
// Union of the StorageProfile and ImageStorageProfile types.
type StorageProfileUnion struct {
ImageReference *compute.ImageReference `json:"imageReference,omitempty"`
OsDisk *OSDiskUnion `json:"osDisk,omitempty"`
}
/////////////////////////////////////////////////
// Template > Resource > Properties
type Properties struct {
@ -50,7 +68,8 @@ type Properties struct {
OsProfile *compute.OSProfile `json:"osProfile,omitempty"`
PublicIPAllocatedMethod *network.IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"`
Sku *Sku `json:"sku,omitempty"`
StorageProfile *compute.StorageProfile `json:"storageProfile,omitempty"`
//StorageProfile3 *compute.StorageProfile `json:"storageProfile,omitempty"`
StorageProfile *StorageProfileUnion `json:"storageProfile,omitempty"`
Subnets *[]network.Subnet `json:"subnets,omitempty"`
TenantId *string `json:"tenantId,omitempty"`
Value *string `json:"value,omitempty"`

@ -122,11 +122,11 @@ func (s *TemplateBuilder) SetManagedDiskUrl(managedDiskImageName, location, blob
Name: to.StringPtr(managedDiskImageName),
Location: to.StringPtr(location),
Properties: &Properties{
StorageProfile: &compute.StorageProfile{
OsDisk: &compute.OSDisk{
StorageProfile: &StorageProfileUnion{
OsDisk: &OSDiskUnion{
OsType: s.osType,
OsState: to.StringPtr(fmt.Sprintf("%s", osState)),
BlobUri: to.StringPtr(blobUri),
OsState: osState,
BlobURI: to.StringPtr(blobUri),
},
},
},

Loading…
Cancel
Save