From 18d7ec96204f2fd82d5960f03a85d66f4f82a250 Mon Sep 17 00:00:00 2001 From: Fabian Kramm Date: Mon, 15 Apr 2024 15:33:52 +0200 Subject: [PATCH] chore: prevent certain pro commands from executing with v0.20 --- cmd/vclusterctl/cmd/import.go | 7 +++++++ cmd/vclusterctl/cmd/login.go | 7 +++++++ cmd/vclusterctl/cmd/logout.go | 7 +++++++ cmd/vclusterctl/cmd/ui.go | 7 +++++++ 4 files changed, 28 insertions(+) diff --git a/cmd/vclusterctl/cmd/import.go b/cmd/vclusterctl/cmd/import.go index b542885b6..9d41c24d7 100644 --- a/cmd/vclusterctl/cmd/import.go +++ b/cmd/vclusterctl/cmd/import.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "os" managementv1 "github.com/loft-sh/api/v3/pkg/apis/management/v1" "github.com/loft-sh/loftctl/v3/pkg/client" @@ -13,6 +14,7 @@ import ( "github.com/loft-sh/log/terminal" "github.com/loft-sh/vcluster/cmd/vclusterctl/cmd/find" "github.com/loft-sh/vcluster/cmd/vclusterctl/flags" + "github.com/loft-sh/vcluster/config" "github.com/loft-sh/vcluster/pkg/procli" "github.com/loft-sh/vcluster/pkg/util/compress" "github.com/mgutz/ansi" @@ -56,6 +58,11 @@ vcluster import my-vcluster --cluster connected-cluster \ Long: description, Args: loftctlUtil.VClusterNameOnlyValidator, RunE: func(cobraCmd *cobra.Command, args []string) error { + if config.ShouldCheckForProFeatures() { + cmd.Log.Warnf("In order to use a Pro feature, please contact us at https://www.vcluster.com/pro-demo or downgrade by running `vcluster upgrade --version v0.19.5`") + os.Exit(0) + } + proClient, err := procli.CreateProClient() if err != nil { return err diff --git a/cmd/vclusterctl/cmd/login.go b/cmd/vclusterctl/cmd/login.go index cc1b642f8..0506e488a 100644 --- a/cmd/vclusterctl/cmd/login.go +++ b/cmd/vclusterctl/cmd/login.go @@ -2,11 +2,13 @@ package cmd import ( "fmt" + "os" "github.com/loft-sh/api/v3/pkg/product" loftctl "github.com/loft-sh/loftctl/v3/cmd/loftctl/cmd" "github.com/loft-sh/log" "github.com/loft-sh/vcluster/cmd/vclusterctl/flags" + "github.com/loft-sh/vcluster/config" "github.com/loft-sh/vcluster/pkg/procli" "github.com/spf13/cobra" ) @@ -39,6 +41,11 @@ vcluster login https://my-vcluster-pro.com --access-key myaccesskey Long: description, Args: cobra.MaximumNArgs(1), RunE: func(cobraCmd *cobra.Command, args []string) error { + if config.ShouldCheckForProFeatures() { + cmd.Log.Warnf("In order to use a Pro feature, please contact us at https://www.vcluster.com/pro-demo or downgrade by running `vcluster upgrade --version v0.19.5`") + os.Exit(0) + } + return cmd.RunLogin(cobraCmd.Context(), args) }, } diff --git a/cmd/vclusterctl/cmd/logout.go b/cmd/vclusterctl/cmd/logout.go index 8e995da32..ae758501b 100644 --- a/cmd/vclusterctl/cmd/logout.go +++ b/cmd/vclusterctl/cmd/logout.go @@ -2,10 +2,12 @@ package cmd import ( "fmt" + "os" loftctl "github.com/loft-sh/loftctl/v3/cmd/loftctl/cmd" "github.com/loft-sh/log" "github.com/loft-sh/vcluster/cmd/vclusterctl/flags" + "github.com/loft-sh/vcluster/config" "github.com/loft-sh/vcluster/pkg/procli" "github.com/spf13/cobra" ) @@ -37,6 +39,11 @@ vcluster logout Long: description, Args: cobra.NoArgs, RunE: func(cobraCmd *cobra.Command, args []string) error { + if config.ShouldCheckForProFeatures() { + cmd.Log.Warnf("In order to use a Pro feature, please contact us at https://www.vcluster.com/pro-demo or downgrade by running `vcluster upgrade --version v0.19.5`") + os.Exit(0) + } + _, err := procli.CreateProClient() if err != nil { return err diff --git a/cmd/vclusterctl/cmd/ui.go b/cmd/vclusterctl/cmd/ui.go index aecf37bf4..ea162199c 100644 --- a/cmd/vclusterctl/cmd/ui.go +++ b/cmd/vclusterctl/cmd/ui.go @@ -3,10 +3,12 @@ package cmd import ( "errors" "fmt" + "os" loftctl "github.com/loft-sh/loftctl/v3/cmd/loftctl/cmd" "github.com/loft-sh/log" "github.com/loft-sh/vcluster/cmd/vclusterctl/flags" + "github.com/loft-sh/vcluster/config" "github.com/loft-sh/vcluster/pkg/procli" "github.com/spf13/cobra" ) @@ -38,6 +40,11 @@ vcluster ui Long: description, Args: cobra.NoArgs, RunE: func(cobraCmd *cobra.Command, args []string) error { + if config.ShouldCheckForProFeatures() { + cmd.Log.Warnf("In order to use a Pro feature, please contact us at https://www.vcluster.com/pro-demo or downgrade by running `vcluster upgrade --version v0.19.5`") + os.Exit(0) + } + err := cmd.Run(cobraCmd.Context(), args) if err != nil { if errors.Is(err, loftctl.ErrNoUrl) {