Skip to content

Commit 4fdc922

Browse files
authored
add GetFamilyName() functionality in skewer (#11)
1 parent b5e8c21 commit 4fdc922

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

data_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ func Test_Data(t *testing.T) {
108108
if name := sku.GetName(); !strings.EqualFold(name, "standard_d4s_v3") {
109109
t.Errorf("expected standard_d4s_v3 to have name standard_d4s_v3, got: '%s'", name)
110110
}
111+
if skuFamily := sku.GetFamilyName(); !strings.EqualFold(skuFamily, "standardDSv3Family") {
112+
t.Errorf("expected standard_d4s_v3 to have name standardDSv3Family, got: '%s'", skuFamily)
113+
}
111114
if resourceType := sku.GetResourceType(); resourceType != VirtualMachines {
112115
t.Errorf("expected standard_d4s_v3 to have resourceType virtual machine, got: '%s'", resourceType)
113116
}
@@ -180,6 +183,9 @@ func Test_Data(t *testing.T) {
180183
if name := sku.GetName(); !strings.EqualFold(name, "standard_d2_v2") {
181184
t.Errorf("expected standard_d2_v2 to have name standard_d2_v2, got: '%s'", name)
182185
}
186+
if skuFamily := sku.GetFamilyName(); !strings.EqualFold(skuFamily, "standardDv2Family") {
187+
t.Errorf("expected standard_d2_v2 to have name standardDv2Family, got: '%s'", skuFamily)
188+
}
183189
if resourceType := sku.GetResourceType(); resourceType != VirtualMachines {
184190
t.Errorf("expected standard_d2_v2 to have resourceType virtual machine, got: '%s'", resourceType)
185191
}

sku.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,17 @@ func (s *SKU) GetName() string {
368368
return *s.Name
369369
}
370370

371+
// GetFamilyName returns the family name of this resource sku. It normalizes pointers
372+
// to the empty string for comparison purposes. For example,
373+
// "standardDSv2Family" for a virtual machine.
374+
func (s *SKU) GetFamilyName() string {
375+
if s.Family == nil {
376+
return ""
377+
}
378+
379+
return *s.Family
380+
}
381+
371382
// GetLocation returns the location for a given SKU.
372383
func (s *SKU) GetLocation() (string, error) {
373384
if s.Locations == nil {

0 commit comments

Comments
 (0)