Skip to content

Commit

Permalink
Only add reset and status subcommands on Linux
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
twz123 committed Nov 15, 2024
1 parent 15586ee commit 662d1e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 0 additions & 4 deletions cmd/reset/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package reset
import (
"fmt"
"os"
"runtime"

"github.com/k0sproject/k0s/pkg/cleanup"
"github.com/k0sproject/k0s/pkg/component/status"
Expand All @@ -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
Expand Down
11 changes: 9 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"net/http"
"os"
"runtime"

"github.com/k0sproject/k0s/cmd/airgap"
"github.com/k0sproject/k0s/cmd/api"
Expand Down Expand Up @@ -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())
Expand Down
7 changes: 0 additions & 7 deletions cmd/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"io"
"path/filepath"
"runtime"

"github.com/k0sproject/k0s/pkg/component/status"
"github.com/k0sproject/k0s/pkg/config"
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 662d1e8

Please sign in to comment.