From a983bd495e8ee858f11de21ec35088d52fa9cfd0 Mon Sep 17 00:00:00 2001 From: Daniel Maizel Date: Mon, 3 Apr 2023 17:52:21 +0300 Subject: [PATCH] Adjust CLI to block uninstall and upgrade for helm runtime (#687) * Adjust CLI to block uninstall and upgrade for helm runtime * bump * fix --- Makefile | 2 +- cmd/commands/common.go | 9 +++++++++ cmd/commands/runtime.go | 13 +++++++++++++ docs/releases/release_notes.md | 4 ++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7d39762d..20140850 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=v0.1.41 +VERSION=v0.1.42 OUT_DIR=dist YEAR?=$(shell date +"%Y") diff --git a/cmd/commands/common.go b/cmd/commands/common.go index 1fb8fd13..81cc790b 100644 --- a/cmd/commands/common.go +++ b/cmd/commands/common.go @@ -767,6 +767,15 @@ func isRuntimeManaged(ctx context.Context, runtimeName string) (bool, error) { return rt.Managed, nil } +func getRuntimeInstallationType(ctx context.Context, runtimeName string) (*platmodel.InstallationType, error) { + rt, err := getRuntime(ctx, runtimeName) + if err != nil { + return nil, err + } + + return &rt.InstallationType, nil +} + func ensureRuntimeOnKubeContext(ctx context.Context, kubeconfig string, runtimeName string, kubeContextName string) error { rt, err := getRuntime(ctx, runtimeName) if err != nil { diff --git a/cmd/commands/runtime.go b/cmd/commands/runtime.go index aca5c445..1a8469c0 100644 --- a/cmd/commands/runtime.go +++ b/cmd/commands/runtime.go @@ -148,6 +148,15 @@ func runtimeUninstallCommandPreRunHandler(cmd *cobra.Command, args []string, opt return err } + installationType, err := getRuntimeInstallationType(ctx, opts.RuntimeName) + if err != nil { + return err + } + + if *installationType == platmodel.InstallationTypeHelm { + return errors.New("This runtime was installed using Helm, please use Helm to uninstall it as well.") + } + if !opts.SkipChecks { opts.Managed, err = isRuntimeManaged(ctx, opts.RuntimeName) if err != nil { @@ -218,6 +227,10 @@ func runtimeUpgradeCommandPreRunHandler(cmd *cobra.Command, args []string, opts return err } + if rt.InstallationType == platmodel.InstallationTypeHelm { + return errors.New("This runtime was installed using Helm, please use Helm to upgrade it as well.") + } + opts.RuntimeNamespace = *rt.Metadata.Namespace if rt.Managed { diff --git a/docs/releases/release_notes.md b/docs/releases/release_notes.md index 40f46dd8..9a921cc6 100644 --- a/docs/releases/release_notes.md +++ b/docs/releases/release_notes.md @@ -23,7 +23,7 @@ cf version ```bash # download and extract the binary -curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.41/cf-linux-amd64.tar.gz | tar zx +curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.42/cf-linux-amd64.tar.gz | tar zx # move the binary to your $PATH mv ./cf-linux-amd64 /usr/local/bin/cf @@ -36,7 +36,7 @@ cf version ```bash # download and extract the binary -curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.41/cf-darwin-amd64.tar.gz | tar zx +curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.42/cf-darwin-amd64.tar.gz | tar zx # move the binary to your $PATH mv ./cf-darwin-amd64 /usr/local/bin/cf