Skip to content

Commit

Permalink
fix: use subscription as the root for azure scrapers
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed May 21, 2024
1 parent 00fe6ee commit 1cb689a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
2 changes: 1 addition & 1 deletion db/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ func setConfigPaths(ctx api.ScrapeContext, tree graph.Graph[string, string], roo

func isTreeRoot(configType string) bool {
switch configType {
case "AWS::::Account", "Kubernetes::Cluster", "Azure::Tenant":
case "AWS::::Account", "Kubernetes::Cluster", "Azure::Subscription":
return true
}

Expand Down
16 changes: 1 addition & 15 deletions scrapers/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const (
ConfigTypePrefix = "Azure::"
defaultActivityLogMaxage = time.Hour * 24 * 7

ResourceTypeTenant = "Tenant"
ResourceTypeSubscription = "Subscription"
)

Expand Down Expand Up @@ -137,15 +136,6 @@ func (azure Scraper) Scrape(ctx api.ScrapeContext) v1.ScrapeResults {
azure.config = &config
azure.cred = cred

// Craft a result for the tenant.
results = append(results, v1.ScrapeResult{
ID: config.TenantID,
Type: getARMType(lo.ToPtr(ResourceTypeTenant)),
BaseScraper: config.BaseScraper,
ConfigClass: "Tenant",
Config: map[string]any{"id": config.TenantID},
})

// We fetch resource groups first as they are used to fetch further resources
results = append(results, azure.fetchResourceGroups()...)
results = append(results, azure.fetchVirtualMachines()...)
Expand Down Expand Up @@ -186,12 +176,8 @@ func (azure Scraper) Scrape(ctx api.ScrapeContext) v1.ScrapeResults {
// Set parents where missing
if results[i].ParentExternalID == "" {
switch results[i].Type {
case getARMType(lo.ToPtr(ResourceTypeTenant)):
continue // root

case getARMType(lo.ToPtr(ResourceTypeSubscription)):
results[i].ParentExternalID = config.TenantID
results[i].ParentType = getARMType(lo.ToPtr(ResourceTypeTenant))
continue // root

default:
subscriptionID := strings.Split(results[i].ID, "/")[2]
Expand Down

0 comments on commit 1cb689a

Please sign in to comment.