Skip to content

Commit

Permalink
WIP Remove global StatusSocket variable
Browse files Browse the repository at this point in the history
...and use the canonical persistent flag set in the status sub-command.

The shared usage of the variable makes the registration order of the
commands change the flag for all of them. This way, the status-socket
flag is no longer the empty string, even if it hasn't been set, which
breaks the sane defaulting.

Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
  • Loading branch information
twz123 committed Dec 20, 2024
1 parent 30674c5 commit e4e72fd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions cmd/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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 @@ -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().AddFlagSet(config.GetPersistentFlagSet())
cmd.AddCommand(NewStatusSubCmdComponents())
return cmd
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/token/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ k0s token create --role worker --expiry 10m //sets expiration time to 10 minute
if err != nil {
return err
}
fmt.Fprintln(cmd.OutOrStdout(), bootstrapToken)
return nil
_, err = fmt.Fprintln(cmd.OutOrStdout(), bootstrapToken)
return err
},
}
// append flags
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 e4e72fd

Please sign in to comment.