Skip to content

Commit

Permalink
Adjust CLI to block uninstall and upgrade for helm runtime (#687)
Browse files Browse the repository at this point in the history
* Adjust CLI to block uninstall and upgrade for helm runtime

* bump

* fix
  • Loading branch information
danielm-codefresh authored Apr 3, 2023
1 parent bf42a1b commit a983bd4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.1.41
VERSION=v0.1.42

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand Down
9 changes: 9 additions & 0 deletions cmd/commands/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions cmd/commands/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions docs/releases/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a983bd4

Please sign in to comment.