|
|
@ -36,6 +36,7 @@ import (
|
|
|
|
"helm.sh/helm/v3/pkg/cli/values"
|
|
|
|
"helm.sh/helm/v3/pkg/cli/values"
|
|
|
|
"helm.sh/helm/v3/pkg/downloader"
|
|
|
|
"helm.sh/helm/v3/pkg/downloader"
|
|
|
|
"helm.sh/helm/v3/pkg/getter"
|
|
|
|
"helm.sh/helm/v3/pkg/getter"
|
|
|
|
|
|
|
|
"helm.sh/helm/v3/pkg/release"
|
|
|
|
"helm.sh/helm/v3/pkg/storage/driver"
|
|
|
|
"helm.sh/helm/v3/pkg/storage/driver"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -120,7 +121,8 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|
|
|
// If a release does not exist, install it.
|
|
|
|
// If a release does not exist, install it.
|
|
|
|
histClient := action.NewHistory(cfg)
|
|
|
|
histClient := action.NewHistory(cfg)
|
|
|
|
histClient.Max = 1
|
|
|
|
histClient.Max = 1
|
|
|
|
if _, err := histClient.Run(args[0]); err == driver.ErrReleaseNotFound {
|
|
|
|
versions, err := histClient.Run(args[0])
|
|
|
|
|
|
|
|
if err == driver.ErrReleaseNotFound || isReleaseUninstalled(versions) {
|
|
|
|
// Only print this to stdout for table output
|
|
|
|
// Only print this to stdout for table output
|
|
|
|
if outfmt == output.Table {
|
|
|
|
if outfmt == output.Table {
|
|
|
|
fmt.Fprintf(out, "Release %q does not exist. Installing it now.\n", args[0])
|
|
|
|
fmt.Fprintf(out, "Release %q does not exist. Installing it now.\n", args[0])
|
|
|
@ -148,6 +150,10 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|
|
|
instClient.EnableDNS = client.EnableDNS
|
|
|
|
instClient.EnableDNS = client.EnableDNS
|
|
|
|
instClient.HideSecret = client.HideSecret
|
|
|
|
instClient.HideSecret = client.HideSecret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if isReleaseUninstalled(versions) {
|
|
|
|
|
|
|
|
instClient.Replace = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rel, err := runInstall(args, instClient, valueOpts, out)
|
|
|
|
rel, err := runInstall(args, instClient, valueOpts, out)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -287,3 +293,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|
|
|
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func isReleaseUninstalled(versions []*release.Release) bool {
|
|
|
|
|
|
|
|
return len(versions) > 0 && versions[len(versions)-1].Info.Status == release.StatusUninstalled
|
|
|
|
|
|
|
|
}
|
|
|
|