From f95db7d68f82f3c353a4c7926bb00a4c8286d216 Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Sat, 21 Dec 2024 00:52:53 +0100 Subject: [PATCH] Remove global StatusSocket variable ...and harmonize the status-socket flag in the status sub-command. The shared use of the StatusSocket variable, along with the non-empty default value in the status sub-command, caused the registration order of sub-commands to change the flag value for each sub-command, even if it wasn't set from the command line. This broke the configuration defaulting. Signed-off-by: Tom Wieczorek --- cmd/status/status.go | 3 +-- pkg/config/cli.go | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/status/status.go b/cmd/status/status.go index ec0f9957104e..20d6de9adc3c 100644 --- a/cmd/status/status.go +++ b/cmd/status/status.go @@ -22,7 +22,6 @@ import ( "encoding/json" "fmt" "io" - "path/filepath" "github.com/k0sproject/k0s/pkg/component/status" "github.com/k0sproject/k0s/pkg/config" @@ -57,7 +56,7 @@ func NewStatusCmd() *cobra.Command { } cmd.PersistentFlags().StringVarP(&output, "out", "o", "", "sets type of output to json or yaml") - cmd.PersistentFlags().StringVar(&config.StatusSocket, "status-socket", filepath.Join(config.K0sVars.RunDir, "status.sock"), "Full file path to the socket file.") + cmd.PersistentFlags().String("status-socket", "", "Full file path to the socket file. (default: /status.sock)") cmd.AddCommand(NewStatusSubCmdComponents()) return cmd } diff --git a/pkg/config/cli.go b/pkg/config/cli.go index 2cca62e56b25..da3e735cb590 100644 --- a/pkg/config/cli.go +++ b/pkg/config/cli.go @@ -36,7 +36,6 @@ var ( CfgFile string Debug bool DebugListenOn string - StatusSocket string K0sVars CfgVars workerOpts WorkerOptions Verbose bool @@ -199,7 +198,7 @@ func GetPersistentFlagSet() *pflag.FlagSet { flagset.BoolVarP(&Debug, "debug", "d", false, "Debug logging (default: false)") flagset.BoolVarP(&Verbose, "verbose", "v", false, "Verbose logging (default: false)") flagset.String("data-dir", constant.DataDirDefault, "Data Directory for k0s. DO NOT CHANGE for an existing setup, things will break!") - flagset.StringVar(&StatusSocket, "status-socket", "", "Full file path to the socket file. (default: /status.sock)") + flagset.String("status-socket", "", "Full file path to the socket file. (default: /status.sock)") flagset.StringVar(&DebugListenOn, "debugListenOn", ":6060", "Http listenOn for Debug pprof handler") return flagset }