Skip to content

Commit

Permalink
feat: Helm direct parent
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Jun 26, 2024
1 parent 705ee54 commit aa5c992
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 0 additions & 4 deletions db/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,10 +730,6 @@ func extractConfigsAndChangesFromResults(ctx api.ScrapeContext, scrapeStartTime

func setConfigParents(ctx api.ScrapeContext, parentTypeToConfigMap map[configExternalKey]string, allConfigs []*models.ConfigItem) error {
for _, ci := range allConfigs {
if ci.ParentID != nil {
continue // existing item. Parent is already set.
}

if len(ci.Parents) == 0 {
continue // these are root items.
}
Expand Down
19 changes: 18 additions & 1 deletion scrapers/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func getKubernetesParent(obj *unstructured.Unstructured, exclusions v1.Kubernete
if obj.GetNamespace() != "" {
parentExternalID := resourceIDMap[""]["Namespace"][obj.GetNamespace()]
if parentExternalID == "" {
// An incremental scraper maynot have the Namespace object.
// An incremental scraper may not have the Namespace object.
// We can instead use the alias as the external id.
parentExternalID = getKubernetesAlias("Namespace", "", obj.GetNamespace())
}
Expand Down Expand Up @@ -645,6 +645,23 @@ func getKubernetesParent(obj *unstructured.Unstructured, exclusions v1.Kubernete
}
}

helmName := obj.GetLabels()["helm.toolkit.fluxcd.io/name"]
helmNamespace := obj.GetLabels()["helm.toolkit.fluxcd.io/namespace"]
if helmName != "" && helmNamespace != "" {
allParents = append([]v1.ConfigExternalKey{{
Type: ConfigTypePrefix + "HelmRelease",
ExternalID: getKubernetesAlias("HelmRelease", helmNamespace, helmName),
}}, allParents...)
}

// TODO: No Namespace or the argo app uid
// if argoApp, ok := obj.GetLabels()["argocd.argoproj.io/instance"]; ok {
// allParents = append([]v1.ConfigExternalKey{{
// Type: ConfigTypePrefix + "Application",
// ExternalID: argoApp,
// }}, allParents...)
// }

return allParents
}

Expand Down

0 comments on commit aa5c992

Please sign in to comment.