From 32f2498140209dd113cd2ab047a1114d8f6827a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wei=C3=9Fe?= Date: Fri, 8 Sep 2023 11:11:05 +0200 Subject: [PATCH] Cleaner cli-config version support checking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weiße --- cli/internal/helm/actionfactory.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/internal/helm/actionfactory.go b/cli/internal/helm/actionfactory.go index 106f9c8b0f..92ae21968f 100644 --- a/cli/internal/helm/actionfactory.go +++ b/cli/internal/helm/actionfactory.go @@ -74,10 +74,12 @@ func (a actionFactory) appendNewAction(release Release, configTargetVersion semv if err != nil { return fmt.Errorf("parsing chart version: %w", err) } + cliSupportsConfigVersion := configTargetVersion.Compare(newVersion) != 0 + currentVersion, err := a.versionLister.currentVersion(release.ReleaseName) if errors.Is(err, errReleaseNotFound) { // Don't install a new release if the user's config specifies a different version than the CLI offers. - if !force && isCLIVersionedRelease(release.ReleaseName) && configTargetVersion.Compare(newVersion) != 0 { + if !force && isCLIVersionedRelease(release.ReleaseName) && cliSupportsConfigVersion { return fmt.Errorf( "unable to install release %s at %s: this CLI only supports microservice version %s for upgrading", release.ReleaseName, configTargetVersion, newVersion, @@ -104,7 +106,7 @@ func (a actionFactory) appendNewAction(release Release, configTargetVersion semv } // Target version is newer than current version, so we should perform an upgrade. // Now make sure the target version is equal to the the CLI version. - if configTargetVersion.Compare(newVersion) != 0 { + if cliSupportsConfigVersion { return fmt.Errorf( "unable to upgrade release %s to %s: this CLI only supports microservice version %s for upgrading", release.ReleaseName, configTargetVersion, newVersion,