Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure flag type consistency #6852

Merged
merged 2 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions pkg/cli/cmds/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,133 +57,133 @@ type AgentShared struct {
var (
appName = filepath.Base(os.Args[0])
AgentConfig Agent
AgentTokenFlag = cli.StringFlag{
AgentTokenFlag = &cli.StringFlag{
Name: "token,t",
Usage: "(cluster) Token to use for authentication",
EnvVar: version.ProgramUpper + "_TOKEN",
Destination: &AgentConfig.Token,
}
NodeIPFlag = cli.StringSliceFlag{
NodeIPFlag = &cli.StringSliceFlag{
Name: "node-ip,i",
Usage: "(agent/networking) IPv4/IPv6 addresses to advertise for node",
Value: &AgentConfig.NodeIP,
}
NodeExternalIPFlag = cli.StringSliceFlag{
NodeExternalIPFlag = &cli.StringSliceFlag{
Name: "node-external-ip",
Usage: "(agent/networking) IPv4/IPv6 external IP addresses to advertise for node",
Value: &AgentConfig.NodeExternalIP,
}
NodeNameFlag = cli.StringFlag{
NodeNameFlag = &cli.StringFlag{
Name: "node-name",
Usage: "(agent/node) Node name",
EnvVar: version.ProgramUpper + "_NODE_NAME",
Destination: &AgentConfig.NodeName,
}
WithNodeIDFlag = cli.BoolFlag{
WithNodeIDFlag = &cli.BoolFlag{
Name: "with-node-id",
Usage: "(agent/node) Append id to node name",
Destination: &AgentConfig.WithNodeID,
}
ProtectKernelDefaultsFlag = cli.BoolFlag{
ProtectKernelDefaultsFlag = &cli.BoolFlag{
Name: "protect-kernel-defaults",
Usage: "(agent/node) Kernel tuning behavior. If set, error if kernel tunables are different than kubelet defaults.",
Destination: &AgentConfig.ProtectKernelDefaults,
}
SELinuxFlag = cli.BoolFlag{
SELinuxFlag = &cli.BoolFlag{
Name: "selinux",
Usage: "(agent/node) Enable SELinux in containerd",
Destination: &AgentConfig.EnableSELinux,
EnvVar: version.ProgramUpper + "_SELINUX",
}
LBServerPortFlag = cli.IntFlag{
LBServerPortFlag = &cli.IntFlag{
Name: "lb-server-port",
Usage: "(agent/node) Local port for supervisor client load-balancer. If the supervisor and apiserver are not colocated an additional port 1 less than this port will also be used for the apiserver client load-balancer.",
Destination: &AgentConfig.LBServerPort,
EnvVar: version.ProgramUpper + "_LB_SERVER_PORT",
Value: 6444,
}
DockerFlag = cli.BoolFlag{
DockerFlag = &cli.BoolFlag{
Name: "docker",
Usage: "(agent/runtime) (experimental) Use cri-dockerd instead of containerd",
Destination: &AgentConfig.Docker,
}
CRIEndpointFlag = cli.StringFlag{
CRIEndpointFlag = &cli.StringFlag{
Name: "container-runtime-endpoint",
Usage: "(agent/runtime) Disable embedded containerd and use the CRI socket at the given path; when used with --docker this sets the docker socket path",
Destination: &AgentConfig.ContainerRuntimeEndpoint,
}
PrivateRegistryFlag = cli.StringFlag{
PrivateRegistryFlag = &cli.StringFlag{
Name: "private-registry",
Usage: "(agent/runtime) Private registry configuration file",
Destination: &AgentConfig.PrivateRegistry,
Value: "/etc/rancher/" + version.Program + "/registries.yaml",
}
AirgapExtraRegistryFlag = cli.StringSliceFlag{
AirgapExtraRegistryFlag = &cli.StringSliceFlag{
Name: "airgap-extra-registry",
Usage: "(agent/runtime) Additional registry to tag airgap images as being sourced from",
Value: &AgentConfig.AirgapExtraRegistry,
Hidden: true,
}
PauseImageFlag = cli.StringFlag{
PauseImageFlag = &cli.StringFlag{
Name: "pause-image",
Usage: "(agent/runtime) Customized pause image for containerd or docker sandbox",
Destination: &AgentConfig.PauseImage,
Value: DefaultPauseImage,
}
SnapshotterFlag = cli.StringFlag{
SnapshotterFlag = &cli.StringFlag{
Name: "snapshotter",
Usage: "(agent/runtime) Override default containerd snapshotter",
Destination: &AgentConfig.Snapshotter,
Value: DefaultSnapshotter,
}
FlannelIfaceFlag = cli.StringFlag{
FlannelIfaceFlag = &cli.StringFlag{
Name: "flannel-iface",
Usage: "(agent/networking) Override default flannel interface",
Destination: &AgentConfig.FlannelIface,
}
FlannelConfFlag = cli.StringFlag{
FlannelConfFlag = &cli.StringFlag{
Name: "flannel-conf",
Usage: "(agent/networking) Override default flannel config file",
Destination: &AgentConfig.FlannelConf,
}
FlannelCniConfFileFlag = cli.StringFlag{
FlannelCniConfFileFlag = &cli.StringFlag{
Name: "flannel-cni-conf",
Usage: "(agent/networking) Override default flannel cni config file",
Destination: &AgentConfig.FlannelCniConfFile,
}
ResolvConfFlag = cli.StringFlag{
ResolvConfFlag = &cli.StringFlag{
Name: "resolv-conf",
Usage: "(agent/networking) Kubelet resolv.conf file",
EnvVar: version.ProgramUpper + "_RESOLV_CONF",
Destination: &AgentConfig.ResolvConf,
}
ExtraKubeletArgs = cli.StringSliceFlag{
ExtraKubeletArgs = &cli.StringSliceFlag{
Name: "kubelet-arg",
Usage: "(agent/flags) Customized flag for kubelet process",
Value: &AgentConfig.ExtraKubeletArgs,
}
ExtraKubeProxyArgs = cli.StringSliceFlag{
ExtraKubeProxyArgs = &cli.StringSliceFlag{
Name: "kube-proxy-arg",
Usage: "(agent/flags) Customized flag for kube-proxy process",
Value: &AgentConfig.ExtraKubeProxyArgs,
}
NodeTaints = cli.StringSliceFlag{
NodeTaints = &cli.StringSliceFlag{
Name: "node-taint",
Usage: "(agent/node) Registering kubelet with set of taints",
Value: &AgentConfig.Taints,
}
NodeLabels = cli.StringSliceFlag{
NodeLabels = &cli.StringSliceFlag{
Name: "node-label",
Usage: "(agent/node) Registering and starting kubelet with set of labels",
Value: &AgentConfig.Labels,
}
ImageCredProvBinDirFlag = cli.StringFlag{
ImageCredProvBinDirFlag = &cli.StringFlag{
Name: "image-credential-provider-bin-dir",
Usage: "(agent/node) The path to the directory where credential provider plugin binaries are located",
Destination: &AgentConfig.ImageCredProvBinDir,
Value: "/var/lib/rancher/credentialprovider/bin",
}
ImageCredProvConfigFlag = cli.StringFlag{
ImageCredProvConfigFlag = &cli.StringFlag{
Name: "image-credential-provider-config",
Usage: "(agent/node) The path to the credential provider plugin config file",
Destination: &AgentConfig.ImageCredProvConfig,
Expand All @@ -205,19 +205,19 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
LogFile,
AlsoLogToStderr,
AgentTokenFlag,
cli.StringFlag{
&cli.StringFlag{
Name: "token-file",
Usage: "(cluster) Token file to use for authentication",
EnvVar: version.ProgramUpper + "_TOKEN_FILE",
Destination: &AgentConfig.TokenFile,
},
cli.StringFlag{
&cli.StringFlag{
Name: "server,s",
Usage: "(cluster) Server to connect to",
EnvVar: version.ProgramUpper + "_URL",
Destination: &AgentConfig.ServerURL,
},
cli.StringFlag{
&cli.StringFlag{
Name: "data-dir,d",
Usage: "(agent/data) Folder to hold state",
Destination: &AgentConfig.DataDir,
Expand All @@ -229,7 +229,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
NodeTaints,
ImageCredProvBinDirFlag,
ImageCredProvConfigFlag,
&SELinuxFlag,
SELinuxFlag,
LBServerPortFlag,
ProtectKernelDefaultsFlag,
CRIEndpointFlag,
Expand All @@ -246,7 +246,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
ExtraKubeletArgs,
ExtraKubeProxyArgs,
// Experimental flags
cli.BoolFlag{
&cli.BoolFlag{
Name: "rootless",
Usage: "(experimental) Run rootless",
Destination: &AgentConfig.Rootless,
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cmds/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var (
LogFile,
AlsoLogToStderr,
DataDirFlag,
cli.StringSliceFlag{
&cli.StringSliceFlag{
Name: "service,s",
Usage: "List of services to rotate certificates for. Options include (admin, api-server, controller-manager, scheduler, " + version.Program + "-controller, " + version.Program + "-server, cloud-controller, etcd, auth-proxy, kubelet, kube-proxy)",
Value: &ServicesList,
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cmds/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func NewCompletionCommand(action func(*cli.Context) error) cli.Command {
UsageText: appName + " completion [SHELL] (valid shells: bash, zsh)",
Action: action,
Flags: []cli.Flag{
cli.BoolFlag{
&cli.BoolFlag{
Name: "i",
Usage: "Install source line to rc file",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cmds/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
var (
// ConfigFlag is here to show to the user, but the actually processing is done by configfileargs before
// call urfave
ConfigFlag = cli.StringFlag{
ConfigFlag = &cli.StringFlag{
Name: "config,c",
Usage: "(config) Load configuration from `FILE`",
EnvVar: version.ProgramUpper + "_CONFIG_FILE",
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cmds/etcd_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var EtcdSnapshotFlags = []cli.Flag{
ConfigFlag,
LogFile,
AlsoLogToStderr,
cli.StringFlag{
&cli.StringFlag{
Name: "node-name",
Usage: "(agent/node) Node name",
EnvVar: version.ProgramUpper + "_NODE_NAME",
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/cmds/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ type Log struct {
var (
LogConfig Log

VLevel = cli.IntFlag{
VLevel = &cli.IntFlag{
Name: "v",
Usage: "(logging) Number for the log level verbosity",
Destination: &LogConfig.VLevel,
}
VModule = cli.StringFlag{
VModule = &cli.StringFlag{
Name: "vmodule",
Usage: "(logging) Comma-separated list of FILE_PATTERN=LOG_LEVEL settings for file-filtered logging",
Destination: &LogConfig.VModule,
}
LogFile = cli.StringFlag{
LogFile = &cli.StringFlag{
Name: "log,l",
Usage: "(logging) Log to file",
Destination: &LogConfig.LogFile,
}
AlsoLogToStderr = cli.BoolFlag{
AlsoLogToStderr = &cli.BoolFlag{
Name: "alsologtostderr",
Usage: "(logging) Log to standard error as well as file (if set)",
Destination: &LogConfig.AlsoLogToStderr,
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/cmds/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (

var (
Debug bool
DebugFlag = cli.BoolFlag{
DebugFlag = &cli.BoolFlag{
Name: "debug",
Usage: "(logging) Turn on debug logs",
Destination: &Debug,
EnvVar: version.ProgramUpper + "_DEBUG",
}
PreferBundledBin = cli.BoolFlag{
PreferBundledBin = &cli.BoolFlag{
Name: "prefer-bundled-bin",
Usage: "(experimental) Prefer bundled userspace binaries over host binaries",
}
Expand All @@ -41,7 +41,7 @@ func NewApp() *cli.App {
}
app.Flags = []cli.Flag{
DebugFlag,
cli.StringFlag{
&cli.StringFlag{
Name: "data-dir,d",
Usage: "(data) Folder to hold state (default: /var/lib/rancher/" + version.Program + " or ${HOME}/.rancher/" + version.Program + " if not root)",
},
Expand Down
10 changes: 5 additions & 5 deletions pkg/cli/cmds/secrets_encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
const SecretsEncryptCommand = "secrets-encrypt"

var (
forceFlag = cli.BoolFlag{
forceFlag = &cli.BoolFlag{
Name: "f,force",
Usage: "Force this stage.",
Destination: &ServerConfig.EncryptForce,
}
EncryptFlags = []cli.Flag{
DataDirFlag,
ServerToken,
cli.StringFlag{
&cli.StringFlag{
Name: "server, s",
Usage: "(cluster) Server to connect to",
EnvVar: version.ProgramUpper + "_URL",
Expand Down Expand Up @@ -62,22 +62,22 @@ func NewSecretsEncryptCommands(status, enable, disable, prepare, rotate, reencry
Usage: "Prepare for encryption keys rotation",
SkipArgReorder: true,
Action: prepare,
Flags: append(EncryptFlags, &forceFlag),
Flags: append(EncryptFlags, forceFlag),
},
{
Name: "rotate",
Usage: "Rotate secrets encryption keys",
SkipArgReorder: true,
Action: rotate,
Flags: append(EncryptFlags, &forceFlag),
Flags: append(EncryptFlags, forceFlag),
},
{
Name: "reencrypt",
Usage: "Reencrypt all data with new encryption key",
SkipArgReorder: true,
Action: reencrypt,
Flags: append(EncryptFlags,
&forceFlag,
forceFlag,
&cli.BoolFlag{
Name: "skip",
Usage: "Skip removing old key",
Expand Down
Loading