From dcd1c8bd1e5bce49b350460e27387e2543102051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wei=C3=9Fe?= Date: Fri, 11 Aug 2023 10:25:57 +0200 Subject: [PATCH] Fix CSI chart version not being compared to CLI version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weiße --- cli/internal/helm/upgrade.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cli/internal/helm/upgrade.go b/cli/internal/helm/upgrade.go index 455c584d0..706ccdb89 100644 --- a/cli/internal/helm/upgrade.go +++ b/cli/internal/helm/upgrade.go @@ -99,12 +99,11 @@ func (c *UpgradeClient) shouldUpgrade(releaseName string, newVersion semver.Semv return err } } - cliVersion := constants.BinaryVersion() + // at this point we conclude that the release should be upgraded. check that this CLI supports the upgrade. - if releaseName == constellationOperatorsInfo.releaseName || releaseName == constellationServicesInfo.releaseName { - if cliVersion.Compare(newVersion) != 0 { - return fmt.Errorf("this CLI only supports microservice version %s for upgrading", cliVersion.String()) - } + cliVersion := constants.BinaryVersion() + if isCLIVersionedRelease(releaseName) && cliVersion.Compare(newVersion) != 0 { + return fmt.Errorf("this CLI only supports microservice version %s for upgrading", cliVersion.String()) } c.log.Debugf("Upgrading %s from %s to %s", releaseName, currentVersion, newVersion) @@ -130,7 +129,7 @@ func (c *UpgradeClient) Upgrade(ctx context.Context, config *config.Config, idFi // Since our bundled charts are embedded with version 0.0.0, // we need to update them to the same version as the CLI var upgradeVersion semver.Semver - if info == constellationOperatorsInfo || info == constellationServicesInfo || info == csiInfo { + if isCLIVersionedRelease(info.releaseName) { updateVersions(chart, constants.BinaryVersion()) upgradeVersion = config.MicroserviceVersion } else { @@ -519,3 +518,11 @@ func (a actions) installAction(ctx context.Context, releaseName string, chart *c } return nil } + +// isCLIVersionedRelease checks if the given release is versioned by the CLI, +// meaning that the version of the Helm release is equal to the version of the CLI that installed it. +func isCLIVersionedRelease(releaseName string) bool { + return releaseName == constellationOperatorsInfo.releaseName || + releaseName == constellationServicesInfo.releaseName || + releaseName == csiInfo.releaseName +}