From c7703943d1aa2061d6f2eb3d9f143ff820ca61d4 Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Tue, 12 Nov 2024 11:07:28 +0100 Subject: [PATCH] Only add reset and status subcommands on Linux They were erroring out on Windows, so remove the OS checks from the commands and only add them on OSes on which they are supported. Signed-off-by: Tom Wieczorek --- cmd/reset/reset.go | 4 ---- cmd/root.go | 11 +++++++++-- cmd/status/status.go | 7 ------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/cmd/reset/reset.go b/cmd/reset/reset.go index 8215fc140142..9e40c220e392 100644 --- a/cmd/reset/reset.go +++ b/cmd/reset/reset.go @@ -19,7 +19,6 @@ package reset import ( "fmt" "os" - "runtime" "github.com/k0sproject/k0s/pkg/cleanup" "github.com/k0sproject/k0s/pkg/component/status" @@ -36,9 +35,6 @@ func NewResetCmd() *cobra.Command { Use: "reset", Short: "Uninstall k0s. Must be run as root (or with sudo)", RunE: func(cmd *cobra.Command, args []string) error { - if runtime.GOOS == "windows" { - return fmt.Errorf("currently not supported on windows") - } opts, err := config.GetCmdOpts(cmd) if err != nil { return err diff --git a/cmd/root.go b/cmd/root.go index dbd9a7bae6e6..573fef3b23c7 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -21,6 +21,7 @@ import ( "fmt" "net/http" "os" + "runtime" "github.com/k0sproject/k0s/cmd/airgap" "github.com/k0sproject/k0s/cmd/api" @@ -91,10 +92,16 @@ func NewRootCmd() *cobra.Command { cmd.AddCommand(install.NewInstallCmd()) cmd.AddCommand(kubeconfig.NewKubeConfigCmd()) cmd.AddCommand(kubectl.NewK0sKubectlCmd()) - cmd.AddCommand(reset.NewResetCmd()) + if runtime.GOOS == "linux" { + // Currently only supported on Linux + cmd.AddCommand(reset.NewResetCmd()) + } cmd.AddCommand(restore.NewRestoreCmd()) cmd.AddCommand(start.NewStartCmd()) - cmd.AddCommand(status.NewStatusCmd()) + if runtime.GOOS == "linux" { + // Currently only supported on Linux + cmd.AddCommand(status.NewStatusCmd()) + } cmd.AddCommand(stop.NewStopCmd()) cmd.AddCommand(sysinfo.NewSysinfoCmd()) cmd.AddCommand(token.NewTokenCmd()) diff --git a/cmd/status/status.go b/cmd/status/status.go index eecf1a1cf73b..25c9aac9141c 100644 --- a/cmd/status/status.go +++ b/cmd/status/status.go @@ -21,7 +21,6 @@ import ( "fmt" "io" "path/filepath" - "runtime" "github.com/k0sproject/k0s/pkg/component/status" "github.com/k0sproject/k0s/pkg/config" @@ -41,9 +40,6 @@ func NewStatusCmd() *cobra.Command { if err != nil { return err } - if runtime.GOOS == "windows" { - return fmt.Errorf("currently not supported on windows") - } statusInfo, err := status.GetStatusInfo(opts.K0sVars.StatusSocketPath) if err != nil { @@ -75,9 +71,6 @@ func NewStatusSubCmdComponents() *cobra.Command { if err != nil { return err } - if runtime.GOOS == "windows" { - return fmt.Errorf("currently not supported on windows") - } fmt.Fprintln(cmd.ErrOrStderr(), "!!! per component status is not yet finally ready, information here might be not full yet") state, err := status.GetComponentStatus(opts.K0sVars.StatusSocketPath, maxCount) if err != nil {