fix(helm3): delete/destroy/apply/sync unable to detect releases to be deleted (#857)
Fixes #853
This commit is contained in:
parent
06b0c99a0b
commit
ef63a05513
|
|
@ -355,7 +355,7 @@ func (st *HelmState) prepareSyncReleases(helm helmexec.Interface, additionalValu
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st *HelmState) isReleaseInstalled(context helmexec.HelmContext, helm helmexec.Interface, release ReleaseSpec) (bool, error) {
|
func (st *HelmState) isReleaseInstalled(context helmexec.HelmContext, helm helmexec.Interface, release ReleaseSpec) (bool, error) {
|
||||||
out, err := helm.List(context, "^"+release.Name+"$", st.connectionFlags(&release)...)
|
out, err := st.listReleases(context, helm, &release)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else if out != "" {
|
} else if out != "" {
|
||||||
|
|
@ -489,9 +489,17 @@ func (st *HelmState) SyncReleases(affectedReleases *AffectedReleases, helm helme
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (st *HelmState) listReleases(context helmexec.HelmContext, helm helmexec.Interface, release *ReleaseSpec) (string, error) {
|
||||||
|
flags := st.connectionFlags(release)
|
||||||
|
if isHelm3() && release.Namespace != "" {
|
||||||
|
flags = append(flags, "--namespace", release.Namespace)
|
||||||
|
}
|
||||||
|
return helm.List(context, "^"+release.Name+"$", flags...)
|
||||||
|
}
|
||||||
|
|
||||||
func (st *HelmState) getDeployedVersion(context helmexec.HelmContext, helm helmexec.Interface, release *ReleaseSpec) (string, error) {
|
func (st *HelmState) getDeployedVersion(context helmexec.HelmContext, helm helmexec.Interface, release *ReleaseSpec) (string, error) {
|
||||||
//retrieve the version
|
//retrieve the version
|
||||||
if out, err := helm.List(context, "^"+release.Name+"$", st.connectionFlags(release)...); err == nil {
|
if out, err := st.listReleases(context, helm, release); err == nil {
|
||||||
chartName := filepath.Base(release.Chart)
|
chartName := filepath.Base(release.Chart)
|
||||||
//the regexp without escapes : .*\s.*\s.*\s.*\schartName-(.*?)\s
|
//the regexp without escapes : .*\s.*\s.*\s.*\schartName-(.*?)\s
|
||||||
pat := regexp.MustCompile(".*\\s.*\\s.*\\s.*\\s" + chartName + "-(.*?)\\s")
|
pat := regexp.MustCompile(".*\\s.*\\s.*\\s.*\\s" + chartName + "-(.*?)\\s")
|
||||||
|
|
|
||||||
|
|
@ -2082,7 +2082,7 @@ func TestHelmState_Delete(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else if !(reflect.DeepEqual(tt.deleted, helm.deleted) && (len(affectedReleases.Deleted) == len(tt.deleted))) {
|
} else if !(reflect.DeepEqual(tt.deleted, helm.deleted) && (len(affectedReleases.Deleted) == len(tt.deleted))) {
|
||||||
t.Errorf("unexpected deletions happened: expected %v, got %v", tt.deleted, &affectedReleases.Deleted)
|
t.Errorf("unexpected deletions happened: expected %v, got %v", tt.deleted, helm.deleted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.Run(tt.name, f)
|
t.Run(tt.name, f)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue