Skip to content

Commit

Permalink
Remove unused config.DataDir global
Browse files Browse the repository at this point in the history
The data-dir is fetched manually from the flag sets nowadays, so
the global variable was not used at all. Also use the standard pflag
defaulting mechanism for printing the defaults.

Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed May 6, 2024
1 parent c2bb053 commit 153331b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Flags:
--cidr-range string HACK: cidr range for the windows worker node \(default "10\.96\.0\.0/12"\)
-c, --config string config file, use '-' to read the config from stdin \(default ".+k0s\.yaml"\)
--cri-socket string container runtime socket to use, default to internal containerd\. Format: \[remote\|docker\]:\[path-to-socket\]
--data-dir string Data Directory for k0s \(default: .+k0s\)\. DO NOT CHANGE for an existing setup, things will break!
--data-dir string Data Directory for k0s\. DO NOT CHANGE for an existing setup, things will break! \(default ".+k0s"\)
-d, --debug Debug logging \(default: false\)
--debugListenOn string Http listenOn for Debug pprof handler \(default ":6060"\)
--disable-components strings disable components \(valid items: applier-manager,autopilot,control-api,coredns,csr-approver,endpoint-reconciler,helm,konnectivity-server,kube-controller-manager,kube-proxy,kube-scheduler,metrics-server,network-provider,node-role,system-rbac,windows-node,worker-config\)
Expand Down
2 changes: 1 addition & 1 deletion cmd/install/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Flags:
--cidr-range string HACK: cidr range for the windows worker node \(default "10\.96\.0\.0/12"\)
-c, --config string config file, use '-' to read the config from stdin \(default ".+k0s\.yaml"\)
--cri-socket string container runtime socket to use, default to internal containerd\. Format: \[remote\|docker\]:\[path-to-socket\]
--data-dir string Data Directory for k0s \(default: .+k0s\)\. DO NOT CHANGE for an existing setup, things will break!
--data-dir string Data Directory for k0s\. DO NOT CHANGE for an existing setup, things will break! \(default ".+k0s"\)
-d, --debug Debug logging \(default: false\)
--debugListenOn string Http listenOn for Debug pprof handler \(default ":6060"\)
--disable-components strings disable components \(valid items: applier-manager,autopilot,control-api,coredns,csr-approver,endpoint-reconciler,helm,konnectivity-server,kube-controller-manager,kube-proxy,kube-scheduler,metrics-server,network-provider,node-role,system-rbac,windows-node,worker-config\)
Expand Down
5 changes: 2 additions & 3 deletions pkg/config/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (

var (
CfgFile string
DataDir string
Debug bool
DebugListenOn string
StatusSocket string
Expand Down Expand Up @@ -124,7 +123,7 @@ func GetPersistentFlagSet() *pflag.FlagSet {
flagset := &pflag.FlagSet{}
flagset.BoolVarP(&Debug, "debug", "d", false, "Debug logging (default: false)")
flagset.BoolVarP(&Verbose, "verbose", "v", false, "Verbose logging (default: false)")
flagset.StringVar(&DataDir, "data-dir", "", "Data Directory for k0s (default: /var/lib/k0s). DO NOT CHANGE for an existing setup, things will break!")
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.StringVar(&DebugListenOn, "debugListenOn", ":6060", "Http listenOn for Debug pprof handler")
return flagset
Expand All @@ -139,7 +138,7 @@ func GetKubeCtlFlagSet() *pflag.FlagSet {
}

flagset := &pflag.FlagSet{}
flagset.StringVar(&DataDir, "data-dir", "", "Data Directory for k0s (default: /var/lib/k0s). DO NOT CHANGE for an existing setup, things will break!")
flagset.String("data-dir", constant.DataDirDefault, "Data Directory for k0s. DO NOT CHANGE for an existing setup, things will break!")
flagset.BoolVar(&Debug, "debug", debugDefault, "Debug logging [$DEBUG]")
return flagset
}
Expand Down

0 comments on commit 153331b

Please sign in to comment.