Skip to content

Commit

Permalink
chore: prevent certain pro commands from executing with v0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianKramm committed Apr 15, 2024
1 parent 1971568 commit 18d7ec9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/vclusterctl/cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions cmd/vclusterctl/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
},
}
Expand Down
7 changes: 7 additions & 0 deletions cmd/vclusterctl/cmd/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions cmd/vclusterctl/cmd/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 18d7ec9

Please sign in to comment.