Skip to content

Commit

Permalink
chore: lowercase azure resource type
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Dec 6, 2023
1 parent 35da69f commit 08954fd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions scrapers/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/subscription/armsubscription"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager"
"github.com/flanksource/commons/logger"
commonutils "github.com/flanksource/commons/utils"
"github.com/flanksource/duty/models"

"github.com/flanksource/config-db/api"
Expand Down Expand Up @@ -434,7 +435,7 @@ func (azure Scraper) fetchSubscriptions() v1.ScrapeResults {
Name: *v.DisplayName,
Config: v,
ConfigClass: "Subscription",
Type: "Azure::SUBSCRIPTION",
Type: getARMType(commonutils.Ptr("subscription")),
})
}
}
Expand Down Expand Up @@ -678,13 +679,13 @@ func getARMID(id *string) string {
// getARMType takes in a type of a resource group
// and returns it in a compatible format.
func getARMType(rType *string) string {
// Need to uppercase the resource type in the config item because
// Need to canonicalize by lowercasing the resource type in the config item because
// the azure advisor recommendation uses resource type in all uppercase; not always but most of the time.
// For example: It returns
// - MICROSOFT.COMPUTE/VIRTUALMACHINES (all caps)
// - Microsoft.ContainerService/ManagedClusters (case not enforced)
// This is required to match config analysis with the config item.
return "Azure::" + strings.ToUpper(deref(rType))
return "Azure::" + strings.ToLower(deref(rType))
}

func extractResourceGroup(resourceID string) string {
Expand Down

0 comments on commit 08954fd

Please sign in to comment.