|
|
@ -33,6 +33,7 @@ import (
|
|
|
|
"helm.sh/helm/v3/pkg/postrender"
|
|
|
|
"helm.sh/helm/v3/pkg/postrender"
|
|
|
|
"helm.sh/helm/v3/pkg/release"
|
|
|
|
"helm.sh/helm/v3/pkg/release"
|
|
|
|
"helm.sh/helm/v3/pkg/releaseutil"
|
|
|
|
"helm.sh/helm/v3/pkg/releaseutil"
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/pkg/storage/driver"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Upgrade is the action for upgrading releases.
|
|
|
|
// Upgrade is the action for upgrading releases.
|
|
|
@ -159,12 +160,33 @@ func (u *Upgrade) prepareUpgrade(name string, chart *chart.Chart, vals map[strin
|
|
|
|
return nil, nil, errMissingChart
|
|
|
|
return nil, nil, errMissingChart
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// finds the deployed release with the given name
|
|
|
|
// finds the last non-deleted release with the given name
|
|
|
|
currentRelease, err := u.cfg.Releases.Deployed(name)
|
|
|
|
lastRelease, err := u.cfg.Releases.Last(name)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
// to keep existing behavior of returning the "%q has no deployed releases" error when an existing release does not exist
|
|
|
|
|
|
|
|
if errors.Is(err, driver.ErrReleaseNotFound) {
|
|
|
|
|
|
|
|
return nil, nil, driver.NewErrNoDeployedReleases(name)
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil, nil, err
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var currentRelease *release.Release
|
|
|
|
|
|
|
|
if lastRelease.Info.Status == release.StatusDeployed {
|
|
|
|
|
|
|
|
// no need to retrieve the last deployed release from storage as the last release is deployed
|
|
|
|
|
|
|
|
currentRelease = lastRelease
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// finds the deployed release with the given name
|
|
|
|
|
|
|
|
currentRelease, err = u.cfg.Releases.Deployed(name)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
if errors.Is(err, driver.ErrNoDeployedReleases) &&
|
|
|
|
|
|
|
|
(lastRelease.Info.Status == release.StatusFailed || lastRelease.Info.Status == release.StatusSuperseded) {
|
|
|
|
|
|
|
|
currentRelease = lastRelease
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// determine if values will be reused
|
|
|
|
// determine if values will be reused
|
|
|
|
vals, err = u.reuseValues(chart, currentRelease, vals)
|
|
|
|
vals, err = u.reuseValues(chart, currentRelease, vals)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -175,12 +197,6 @@ func (u *Upgrade) prepareUpgrade(name string, chart *chart.Chart, vals map[strin
|
|
|
|
return nil, nil, err
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// finds the non-deleted release with the given name
|
|
|
|
|
|
|
|
lastRelease, err := u.cfg.Releases.Last(name)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Increment revision count. This is passed to templates, and also stored on
|
|
|
|
// Increment revision count. This is passed to templates, and also stored on
|
|
|
|
// the release object.
|
|
|
|
// the release object.
|
|
|
|
revision := lastRelease.Version + 1
|
|
|
|
revision := lastRelease.Version + 1
|
|
|
|