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:
pjotre86 2021-10-22 01:29:33 +02:00 committed by GitHub
parent c0668874e3
commit 9354c38a0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 7 deletions

View File

@ -1190,11 +1190,27 @@ func collectNeeds(release state.ReleaseSpec, selectedIds map[string]struct{}, ne
for _, id := range release.Needs {
// Avoids duplicating a release that is selected AND also needed by another selected release
if _, ok := selectedIds[id]; !ok {
if _, ok := needed[id]; !ok {
needed[id] = struct{}{}
if includeTransitiveNeeds {
releaseParts := strings.Split(id, "/")
releaseName := releaseParts[len(releaseParts)-1]
releasePartsCount := len(releaseParts)
releaseName := releaseParts[releasePartsCount-1]
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)
}
@ -1203,6 +1219,7 @@ func collectNeeds(release state.ReleaseSpec, selectedIds map[string]struct{}, ne
}
}
}
}
func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) {
st := r.state