fix: Check needs with context and namespace

Signed-off-by: André Arnqvist <andrearnqvist@gmail.com>
This commit is contained in:
André Arnqvist 2025-04-02 17:52:10 +02:00
parent 2076515c5d
commit 015508177a
No known key found for this signature in database
GPG Key ID: 1187A78F40D8C6FE
1 changed files with 5 additions and 4 deletions

View File

@ -488,7 +488,7 @@ func (st *HelmState) reformat(spec *ReleaseSpec) []string {
var needs []string
releaseInstalledInfo := make(map[string]bool)
for _, r := range st.OrginReleases {
releaseInstalledInfo[r.Name] = r.Desired()
releaseInstalledInfo[fmt.Sprintf("%s/%s/%s", r.KubeContext, r.Namespace, r.Name)] = r.Desired()
}
// Since the representation differs between needs and id,
@ -501,9 +501,6 @@ func (st *HelmState) reformat(spec *ReleaseSpec) []string {
components := strings.Split(n, "/")
name = components[len(components)-1]
if spec.Desired() && !releaseInstalledInfo[name] {
st.logger.Warnf("WARNING: %s", fmt.Sprintf("release %s needs %s, but %s is not installed due to installed: false. Either mark %s as installed or remove %s from %s's needs", spec.Name, name, name, name, name, spec.Name))
}
if len(components) > 1 {
ns = components[len(components)-2]
@ -519,6 +516,10 @@ func (st *HelmState) reformat(spec *ReleaseSpec) []string {
kubecontext = spec.KubeContext
}
if spec.Desired() && !releaseInstalledInfo[fmt.Sprintf("%s/%s/%s", kubecontext, ns, name)] {
st.logger.Warnf("WARNING: %s", fmt.Sprintf("release %s needs %s, but %s is not installed due to installed: false. Either mark %s as installed or remove %s from %s's needs", spec.Name, name, name, name, name, spec.Name))
}
var componentsAfterOverride []string
if kubecontext != "" {