Skip to content

Commit

Permalink
add GetFamilyName() functionality in skewer (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
gandhipr committed Mar 10, 2022
1 parent b5e8c21 commit 4fdc922
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ func Test_Data(t *testing.T) {
if name := sku.GetName(); !strings.EqualFold(name, "standard_d4s_v3") {
t.Errorf("expected standard_d4s_v3 to have name standard_d4s_v3, got: '%s'", name)
}
if skuFamily := sku.GetFamilyName(); !strings.EqualFold(skuFamily, "standardDSv3Family") {
t.Errorf("expected standard_d4s_v3 to have name standardDSv3Family, got: '%s'", skuFamily)
}
if resourceType := sku.GetResourceType(); resourceType != VirtualMachines {
t.Errorf("expected standard_d4s_v3 to have resourceType virtual machine, got: '%s'", resourceType)
}
Expand Down Expand Up @@ -180,6 +183,9 @@ func Test_Data(t *testing.T) {
if name := sku.GetName(); !strings.EqualFold(name, "standard_d2_v2") {
t.Errorf("expected standard_d2_v2 to have name standard_d2_v2, got: '%s'", name)
}
if skuFamily := sku.GetFamilyName(); !strings.EqualFold(skuFamily, "standardDv2Family") {
t.Errorf("expected standard_d2_v2 to have name standardDv2Family, got: '%s'", skuFamily)
}
if resourceType := sku.GetResourceType(); resourceType != VirtualMachines {
t.Errorf("expected standard_d2_v2 to have resourceType virtual machine, got: '%s'", resourceType)
}
Expand Down
11 changes: 11 additions & 0 deletions sku.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,17 @@ func (s *SKU) GetName() string {
return *s.Name
}

// GetFamilyName returns the family name of this resource sku. It normalizes pointers
// to the empty string for comparison purposes. For example,
// "standardDSv2Family" for a virtual machine.
func (s *SKU) GetFamilyName() string {
if s.Family == nil {
return ""
}

return *s.Family
}

// GetLocation returns the location for a given SKU.
func (s *SKU) GetLocation() (string, error) {
if s.Locations == nil {
Expand Down

0 comments on commit 4fdc922

Please sign in to comment.