Skip to content

Commit

Permalink
Remove global StatusSocket variable
Browse files Browse the repository at this point in the history
...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 <[email protected]>
  • Loading branch information
twz123 committed Dec 24, 2024
1 parent a5f42ef commit e44d700
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions cmd/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"encoding/json"
"fmt"
"io"
"path/filepath"

"github.com/k0sproject/k0s/pkg/component/status"
"github.com/k0sproject/k0s/pkg/config"
Expand Down Expand Up @@ -56,7 +55,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: <rundir>/status.sock)")
cmd.AddCommand(NewStatusSubCmdComponents())
return cmd
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/config/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var (
CfgFile string
Debug bool
DebugListenOn string
StatusSocket string
K0sVars CfgVars
workerOpts WorkerOptions
Verbose bool
Expand Down Expand Up @@ -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: <rundir>/status.sock)")
flagset.String("status-socket", "", "Full file path to the socket file. (default: <rundir>/status.sock)")
flagset.StringVar(&DebugListenOn, "debugListenOn", ":6060", "Http listenOn for Debug pprof handler")
return flagset
}
Expand Down

0 comments on commit e44d700

Please sign in to comment.