Process feedback for pr 1983 (#1992)
* Guard collectNeeds-method against infinite recursion. * Also check for namespace and kubecontext when collecting needs. Co-authored-by: Peter Aichinger <petera@topdesk.com>
This commit is contained in:
parent
c0668874e3
commit
9354c38a0a
|
|
@ -1190,13 +1190,30 @@ func collectNeeds(release state.ReleaseSpec, selectedIds map[string]struct{}, ne
|
||||||
for _, id := range release.Needs {
|
for _, id := range release.Needs {
|
||||||
// Avoids duplicating a release that is selected AND also needed by another selected release
|
// Avoids duplicating a release that is selected AND also needed by another selected release
|
||||||
if _, ok := selectedIds[id]; !ok {
|
if _, ok := selectedIds[id]; !ok {
|
||||||
needed[id] = struct{}{}
|
if _, ok := needed[id]; !ok {
|
||||||
if includeTransitiveNeeds {
|
needed[id] = struct{}{}
|
||||||
releaseParts := strings.Split(id, "/")
|
if includeTransitiveNeeds {
|
||||||
releaseName := releaseParts[len(releaseParts)-1]
|
releaseParts := strings.Split(id, "/")
|
||||||
for _, r := range allReleases {
|
releasePartsCount := len(releaseParts)
|
||||||
if r.Name == releaseName {
|
releaseName := releaseParts[releasePartsCount-1]
|
||||||
collectNeeds(r, selectedIds, needed, allReleases, includeTransitiveNeeds)
|
releaseNamespace := ""
|
||||||
|
releaseKubeContext := ""
|
||||||
|
if releasePartsCount > 1 {
|
||||||
|
releaseNamespace = releaseParts[releasePartsCount-2]
|
||||||
|
}
|
||||||
|
if releasePartsCount > 2 {
|
||||||
|
releaseKubeContext = releaseParts[releasePartsCount-3]
|
||||||
|
}
|
||||||
|
for _, r := range allReleases {
|
||||||
|
if len(releaseNamespace) > 0 && r.Namespace != releaseNamespace {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(releaseKubeContext) > 0 && r.KubeContext != releaseKubeContext {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if r.Name == releaseName {
|
||||||
|
collectNeeds(r, selectedIds, needed, allReleases, includeTransitiveNeeds)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue