feat(arm-builder): zone resilient from config

This commit is contained in:
Manuel Riezebosch 2019-01-17 09:01:42 +01:00
parent be21850e32
commit f31031f6b1
3 changed files with 52 additions and 0 deletions

View File

@ -107,6 +107,7 @@ type Config struct {
ManagedImageOSDiskSnapshotName string `mapstructure:"managed_image_os_disk_snapshot_name"` ManagedImageOSDiskSnapshotName string `mapstructure:"managed_image_os_disk_snapshot_name"`
ManagedImageDataDiskSnapshotPrefix string `mapstructure:"managed_image_data_disk_snapshot_prefix"` ManagedImageDataDiskSnapshotPrefix string `mapstructure:"managed_image_data_disk_snapshot_prefix"`
manageImageLocation string manageImageLocation string
ManagedImageZoneResilient bool `mapstructure:"managed_image_zone_resilient"`
// Deployment // Deployment
AzureTags map[string]*string `mapstructure:"azure_tags"` AzureTags map[string]*string `mapstructure:"azure_tags"`
@ -196,6 +197,9 @@ func (c *Config) toImageParameters() *compute.Image {
SourceVirtualMachine: &compute.SubResource{ SourceVirtualMachine: &compute.SubResource{
ID: to.StringPtr(c.toVMID()), ID: to.StringPtr(c.toVMID()),
}, },
StorageProfile: &compute.ImageStorageProfile{
ZoneResilient: to.BoolPtr(c.ManagedImageZoneResilient),
},
}, },
Location: to.StringPtr(c.Location), Location: to.StringPtr(c.Location),
Tags: c.AzureTags, Tags: c.AzureTags,

View File

@ -794,6 +794,51 @@ func TestConfigShouldRejectExcessiveTagValueLength(t *testing.T) {
} }
} }
func TestConfigZoneResilientShouldDefaultToFalse(t *testing.T) {
config := map[string]interface{}{
"managed_image_name": "ignore",
"managed_image_resource_group_name": "ignore",
"build_resource_group_name": "ignore",
"image_publisher": "igore",
"image_offer": "ignore",
"image_sku": "ignore",
"os_type": "linux",
}
c, _, err := newConfig(config, getPackerConfiguration())
if err != nil {
t.Fatal(err)
}
p := c.toImageParameters()
if *p.ImageProperties.StorageProfile.ZoneResilient {
t.Fatal("expected zone resilient default to be false")
}
}
func TestConfigZoneResilientSetFromConfig(t *testing.T) {
config := map[string]interface{}{
"managed_image_name": "ignore",
"managed_image_resource_group_name": "ignore",
"build_resource_group_name": "ignore",
"image_publisher": "igore",
"image_offer": "ignore",
"image_sku": "ignore",
"os_type": "linux",
"managed_image_zone_resilient": true,
}
c, _, err := newConfig(config, getPackerConfiguration())
if err != nil {
t.Fatal(err)
}
p := c.toImageParameters()
if *p.ImageProperties.StorageProfile.ZoneResilient == false {
t.Fatal("expected managed image zone resilient to be true from config")
}
}
func TestConfigShouldRejectMissingCustomDataFile(t *testing.T) { func TestConfigShouldRejectMissingCustomDataFile(t *testing.T) {
config := map[string]interface{}{ config := map[string]interface{}{
"capture_name_prefix": "ignore", "capture_name_prefix": "ignore",

View File

@ -333,6 +333,9 @@ Providing `temp_resource_group_name` or `location` in combination with
is set, snapshot of the data disk(s) is created with the same prefix as this value before the VM is set, snapshot of the data disk(s) is created with the same prefix as this value before the VM
is captured. is captured.
- `managed_image_zone_resilient` (bool) Store the image in zone-resilient storage. You need to create it
in a region that supports [availability zones](https://docs.microsoft.com/en-us/azure/availability-zones/az-overview).
## Basic Example ## Basic Example
Here is a basic example for Azure. Here is a basic example for Azure.