diff --git a/const.go b/const.go index d39808d..d504b23 100644 --- a/const.go +++ b/const.go @@ -57,6 +57,8 @@ const ( SupportedEphemeralOSDiskPlacements = "SupportedEphemeralOSDiskPlacements" // NvmeDiskSizeInMiB identifies the NVMe disk size in MiB. NvmeDiskSizeInMiB = "NvmeDiskSizeInMiB" + // LowPriorityCapable identifies the capability for low priority VM support. + LowPriorityCapable = "LowPriorityCapable" ) const ( diff --git a/sku.go b/sku.go index 87ac4a4..253b0a8 100644 --- a/sku.go +++ b/sku.go @@ -121,6 +121,11 @@ func (s *SKU) IsPremiumIO() bool { return s.HasCapability(CapabilityPremiumIO) } +// IsLowPriorityCapable returns true when the VM size supports low priority VMs. +func (s *SKU) IsLowPriorityCapable() bool { + return s.HasCapability(LowPriorityCapable) +} + // IsHyperVGen1Supported returns true when the VM size supports // accelerated networking. func (s *SKU) IsHyperVGen1Supported() bool { diff --git a/sku_test.go b/sku_test.go index 371eba3..3404287 100644 --- a/sku_test.go +++ b/sku_test.go @@ -778,3 +778,45 @@ func Test_SKU_Includes(t *testing.T) { }) } } + +func Test_SKU_IsLowPriorityCapable(t *testing.T) { + cases := map[string]struct { + sku compute.ResourceSku + expect bool + }{ + "should return false when no capabilities": { + sku: compute.ResourceSku{}, + }, + "should return false when capability is False": { + sku: compute.ResourceSku{ + Capabilities: &[]compute.ResourceSkuCapabilities{ + { + Name: to.StringPtr(LowPriorityCapable), + Value: to.StringPtr("False"), + }, + }, + }, + }, + "should return true when capability is True": { + sku: compute.ResourceSku{ + Capabilities: &[]compute.ResourceSkuCapabilities{ + { + Name: to.StringPtr(LowPriorityCapable), + Value: to.StringPtr("True"), + }, + }, + }, + expect: true, + }, + } + + for name, tc := range cases { + tc := tc + t.Run(name, func(t *testing.T) { + sku := SKU(tc.sku) + if diff := cmp.Diff(tc.expect, sku.IsLowPriorityCapable()); diff != "" { + t.Error(diff) + } + }) + } +} diff --git a/v2/const.go b/v2/const.go index d39808d..d504b23 100644 --- a/v2/const.go +++ b/v2/const.go @@ -57,6 +57,8 @@ const ( SupportedEphemeralOSDiskPlacements = "SupportedEphemeralOSDiskPlacements" // NvmeDiskSizeInMiB identifies the NVMe disk size in MiB. NvmeDiskSizeInMiB = "NvmeDiskSizeInMiB" + // LowPriorityCapable identifies the capability for low priority VM support. + LowPriorityCapable = "LowPriorityCapable" ) const ( diff --git a/v2/sku.go b/v2/sku.go index b3623a6..09a9d94 100644 --- a/v2/sku.go +++ b/v2/sku.go @@ -121,6 +121,11 @@ func (s *SKU) IsPremiumIO() bool { return s.HasCapability(CapabilityPremiumIO) } +// IsLowPriorityCapable returns true when the VM size supports low priority VMs. +func (s *SKU) IsLowPriorityCapable() bool { + return s.HasCapability(LowPriorityCapable) +} + // IsHyperVGen1Supported returns true when the VM size supports // accelerated networking. func (s *SKU) IsHyperVGen1Supported() bool { diff --git a/v2/sku_test.go b/v2/sku_test.go index f81cf1f..bee44a0 100644 --- a/v2/sku_test.go +++ b/v2/sku_test.go @@ -776,3 +776,45 @@ func Test_SKU_Includes(t *testing.T) { }) } } + +func Test_SKU_IsLowPriorityCapable(t *testing.T) { + cases := map[string]struct { + sku armcompute.ResourceSKU + expect bool + }{ + "should return false when no capabilities": { + sku: armcompute.ResourceSKU{}, + }, + "should return false when capability is False": { + sku: armcompute.ResourceSKU{ + Capabilities: []*armcompute.ResourceSKUCapabilities{ + { + Name: to.Ptr(LowPriorityCapable), + Value: to.Ptr("False"), + }, + }, + }, + }, + "should return true when capability is True": { + sku: armcompute.ResourceSKU{ + Capabilities: []*armcompute.ResourceSKUCapabilities{ + { + Name: to.Ptr(LowPriorityCapable), + Value: to.Ptr("True"), + }, + }, + }, + expect: true, + }, + } + + for name, tc := range cases { + tc := tc + t.Run(name, func(t *testing.T) { + sku := SKU(tc.sku) + if diff := cmp.Diff(tc.expect, sku.IsLowPriorityCapable()); diff != "" { + t.Error(diff) + } + }) + } +}