Unverified Commit f4a75678 authored by Derek Nola's avatar Derek Nola Committed by GitHub

[Release-1.25] Ensure flag type consistency (#6867)

* Standardize flag declaration Signed-off-by: 's avatarDerek Nola <derek.nola@suse.com>
parent 9874f95d
...@@ -59,133 +59,133 @@ type AgentShared struct { ...@@ -59,133 +59,133 @@ type AgentShared struct {
var ( var (
appName = filepath.Base(os.Args[0]) appName = filepath.Base(os.Args[0])
AgentConfig Agent AgentConfig Agent
AgentTokenFlag = cli.StringFlag{ AgentTokenFlag = &cli.StringFlag{
Name: "token,t", Name: "token,t",
Usage: "(cluster) Token to use for authentication", Usage: "(cluster) Token to use for authentication",
EnvVar: version.ProgramUpper + "_TOKEN", EnvVar: version.ProgramUpper + "_TOKEN",
Destination: &AgentConfig.Token, Destination: &AgentConfig.Token,
} }
NodeIPFlag = cli.StringSliceFlag{ NodeIPFlag = &cli.StringSliceFlag{
Name: "node-ip,i", Name: "node-ip,i",
Usage: "(agent/networking) IPv4/IPv6 addresses to advertise for node", Usage: "(agent/networking) IPv4/IPv6 addresses to advertise for node",
Value: &AgentConfig.NodeIP, Value: &AgentConfig.NodeIP,
} }
NodeExternalIPFlag = cli.StringSliceFlag{ NodeExternalIPFlag = &cli.StringSliceFlag{
Name: "node-external-ip", Name: "node-external-ip",
Usage: "(agent/networking) IPv4/IPv6 external IP addresses to advertise for node", Usage: "(agent/networking) IPv4/IPv6 external IP addresses to advertise for node",
Value: &AgentConfig.NodeExternalIP, Value: &AgentConfig.NodeExternalIP,
} }
NodeNameFlag = cli.StringFlag{ NodeNameFlag = &cli.StringFlag{
Name: "node-name", Name: "node-name",
Usage: "(agent/node) Node name", Usage: "(agent/node) Node name",
EnvVar: version.ProgramUpper + "_NODE_NAME", EnvVar: version.ProgramUpper + "_NODE_NAME",
Destination: &AgentConfig.NodeName, Destination: &AgentConfig.NodeName,
} }
WithNodeIDFlag = cli.BoolFlag{ WithNodeIDFlag = &cli.BoolFlag{
Name: "with-node-id", Name: "with-node-id",
Usage: "(agent/node) Append id to node name", Usage: "(agent/node) Append id to node name",
Destination: &AgentConfig.WithNodeID, Destination: &AgentConfig.WithNodeID,
} }
ProtectKernelDefaultsFlag = cli.BoolFlag{ ProtectKernelDefaultsFlag = &cli.BoolFlag{
Name: "protect-kernel-defaults", Name: "protect-kernel-defaults",
Usage: "(agent/node) Kernel tuning behavior. If set, error if kernel tunables are different than kubelet defaults.", Usage: "(agent/node) Kernel tuning behavior. If set, error if kernel tunables are different than kubelet defaults.",
Destination: &AgentConfig.ProtectKernelDefaults, Destination: &AgentConfig.ProtectKernelDefaults,
} }
SELinuxFlag = cli.BoolFlag{ SELinuxFlag = &cli.BoolFlag{
Name: "selinux", Name: "selinux",
Usage: "(agent/node) Enable SELinux in containerd", Usage: "(agent/node) Enable SELinux in containerd",
Destination: &AgentConfig.EnableSELinux, Destination: &AgentConfig.EnableSELinux,
EnvVar: version.ProgramUpper + "_SELINUX", EnvVar: version.ProgramUpper + "_SELINUX",
} }
LBServerPortFlag = cli.IntFlag{ LBServerPortFlag = &cli.IntFlag{
Name: "lb-server-port", 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.", 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, Destination: &AgentConfig.LBServerPort,
EnvVar: version.ProgramUpper + "_LB_SERVER_PORT", EnvVar: version.ProgramUpper + "_LB_SERVER_PORT",
Value: 6444, Value: 6444,
} }
DockerFlag = cli.BoolFlag{ DockerFlag = &cli.BoolFlag{
Name: "docker", Name: "docker",
Usage: "(agent/runtime) (experimental) Use cri-dockerd instead of containerd", Usage: "(agent/runtime) (experimental) Use cri-dockerd instead of containerd",
Destination: &AgentConfig.Docker, Destination: &AgentConfig.Docker,
} }
CRIEndpointFlag = cli.StringFlag{ CRIEndpointFlag = &cli.StringFlag{
Name: "container-runtime-endpoint", 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", 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, Destination: &AgentConfig.ContainerRuntimeEndpoint,
} }
PrivateRegistryFlag = cli.StringFlag{ PrivateRegistryFlag = &cli.StringFlag{
Name: "private-registry", Name: "private-registry",
Usage: "(agent/runtime) Private registry configuration file", Usage: "(agent/runtime) Private registry configuration file",
Destination: &AgentConfig.PrivateRegistry, Destination: &AgentConfig.PrivateRegistry,
Value: "/etc/rancher/" + version.Program + "/registries.yaml", Value: "/etc/rancher/" + version.Program + "/registries.yaml",
} }
AirgapExtraRegistryFlag = cli.StringSliceFlag{ AirgapExtraRegistryFlag = &cli.StringSliceFlag{
Name: "airgap-extra-registry", Name: "airgap-extra-registry",
Usage: "(agent/runtime) Additional registry to tag airgap images as being sourced from", Usage: "(agent/runtime) Additional registry to tag airgap images as being sourced from",
Value: &AgentConfig.AirgapExtraRegistry, Value: &AgentConfig.AirgapExtraRegistry,
Hidden: true, Hidden: true,
} }
PauseImageFlag = cli.StringFlag{ PauseImageFlag = &cli.StringFlag{
Name: "pause-image", Name: "pause-image",
Usage: "(agent/runtime) Customized pause image for containerd or docker sandbox", Usage: "(agent/runtime) Customized pause image for containerd or docker sandbox",
Destination: &AgentConfig.PauseImage, Destination: &AgentConfig.PauseImage,
Value: DefaultPauseImage, Value: DefaultPauseImage,
} }
SnapshotterFlag = cli.StringFlag{ SnapshotterFlag = &cli.StringFlag{
Name: "snapshotter", Name: "snapshotter",
Usage: "(agent/runtime) Override default containerd snapshotter", Usage: "(agent/runtime) Override default containerd snapshotter",
Destination: &AgentConfig.Snapshotter, Destination: &AgentConfig.Snapshotter,
Value: DefaultSnapshotter, Value: DefaultSnapshotter,
} }
FlannelIfaceFlag = cli.StringFlag{ FlannelIfaceFlag = &cli.StringFlag{
Name: "flannel-iface", Name: "flannel-iface",
Usage: "(agent/networking) Override default flannel interface", Usage: "(agent/networking) Override default flannel interface",
Destination: &AgentConfig.FlannelIface, Destination: &AgentConfig.FlannelIface,
} }
FlannelConfFlag = cli.StringFlag{ FlannelConfFlag = &cli.StringFlag{
Name: "flannel-conf", Name: "flannel-conf",
Usage: "(agent/networking) Override default flannel config file", Usage: "(agent/networking) Override default flannel config file",
Destination: &AgentConfig.FlannelConf, Destination: &AgentConfig.FlannelConf,
} }
FlannelCniConfFileFlag = cli.StringFlag{ FlannelCniConfFileFlag = &cli.StringFlag{
Name: "flannel-cni-conf", Name: "flannel-cni-conf",
Usage: "(agent/networking) Override default flannel cni config file", Usage: "(agent/networking) Override default flannel cni config file",
Destination: &AgentConfig.FlannelCniConfFile, Destination: &AgentConfig.FlannelCniConfFile,
} }
ResolvConfFlag = cli.StringFlag{ ResolvConfFlag = &cli.StringFlag{
Name: "resolv-conf", Name: "resolv-conf",
Usage: "(agent/networking) Kubelet resolv.conf file", Usage: "(agent/networking) Kubelet resolv.conf file",
EnvVar: version.ProgramUpper + "_RESOLV_CONF", EnvVar: version.ProgramUpper + "_RESOLV_CONF",
Destination: &AgentConfig.ResolvConf, Destination: &AgentConfig.ResolvConf,
} }
ExtraKubeletArgs = cli.StringSliceFlag{ ExtraKubeletArgs = &cli.StringSliceFlag{
Name: "kubelet-arg", Name: "kubelet-arg",
Usage: "(agent/flags) Customized flag for kubelet process", Usage: "(agent/flags) Customized flag for kubelet process",
Value: &AgentConfig.ExtraKubeletArgs, Value: &AgentConfig.ExtraKubeletArgs,
} }
ExtraKubeProxyArgs = cli.StringSliceFlag{ ExtraKubeProxyArgs = &cli.StringSliceFlag{
Name: "kube-proxy-arg", Name: "kube-proxy-arg",
Usage: "(agent/flags) Customized flag for kube-proxy process", Usage: "(agent/flags) Customized flag for kube-proxy process",
Value: &AgentConfig.ExtraKubeProxyArgs, Value: &AgentConfig.ExtraKubeProxyArgs,
} }
NodeTaints = cli.StringSliceFlag{ NodeTaints = &cli.StringSliceFlag{
Name: "node-taint", Name: "node-taint",
Usage: "(agent/node) Registering kubelet with set of taints", Usage: "(agent/node) Registering kubelet with set of taints",
Value: &AgentConfig.Taints, Value: &AgentConfig.Taints,
} }
NodeLabels = cli.StringSliceFlag{ NodeLabels = &cli.StringSliceFlag{
Name: "node-label", Name: "node-label",
Usage: "(agent/node) Registering and starting kubelet with set of labels", Usage: "(agent/node) Registering and starting kubelet with set of labels",
Value: &AgentConfig.Labels, Value: &AgentConfig.Labels,
} }
ImageCredProvBinDirFlag = cli.StringFlag{ ImageCredProvBinDirFlag = &cli.StringFlag{
Name: "image-credential-provider-bin-dir", Name: "image-credential-provider-bin-dir",
Usage: "(agent/node) The path to the directory where credential provider plugin binaries are located", Usage: "(agent/node) The path to the directory where credential provider plugin binaries are located",
Destination: &AgentConfig.ImageCredProvBinDir, Destination: &AgentConfig.ImageCredProvBinDir,
Value: "/var/lib/rancher/credentialprovider/bin", Value: "/var/lib/rancher/credentialprovider/bin",
} }
ImageCredProvConfigFlag = cli.StringFlag{ ImageCredProvConfigFlag = &cli.StringFlag{
Name: "image-credential-provider-config", Name: "image-credential-provider-config",
Usage: "(agent/node) The path to the credential provider plugin config file", Usage: "(agent/node) The path to the credential provider plugin config file",
Destination: &AgentConfig.ImageCredProvConfig, Destination: &AgentConfig.ImageCredProvConfig,
...@@ -196,7 +196,7 @@ var ( ...@@ -196,7 +196,7 @@ var (
Usage: "(deprecated) Use --selinux to explicitly enable SELinux", Usage: "(deprecated) Use --selinux to explicitly enable SELinux",
Hidden: true, Hidden: true,
} }
FlannelFlag = cli.BoolFlag{ FlannelFlag = &cli.BoolFlag{
Hidden: true, Hidden: true,
Name: "no-flannel", Name: "no-flannel",
Usage: "(deprecated) use --flannel-backend=none", Usage: "(deprecated) use --flannel-backend=none",
...@@ -229,19 +229,19 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command { ...@@ -229,19 +229,19 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
LogFile, LogFile,
AlsoLogToStderr, AlsoLogToStderr,
AgentTokenFlag, AgentTokenFlag,
cli.StringFlag{ &cli.StringFlag{
Name: "token-file", Name: "token-file",
Usage: "(cluster) Token file to use for authentication", Usage: "(cluster) Token file to use for authentication",
EnvVar: version.ProgramUpper + "_TOKEN_FILE", EnvVar: version.ProgramUpper + "_TOKEN_FILE",
Destination: &AgentConfig.TokenFile, Destination: &AgentConfig.TokenFile,
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "server,s", Name: "server,s",
Usage: "(cluster) Server to connect to", Usage: "(cluster) Server to connect to",
EnvVar: version.ProgramUpper + "_URL", EnvVar: version.ProgramUpper + "_URL",
Destination: &AgentConfig.ServerURL, Destination: &AgentConfig.ServerURL,
}, },
cli.StringFlag{ &cli.StringFlag{
Name: "data-dir,d", Name: "data-dir,d",
Usage: "(agent/data) Folder to hold state", Usage: "(agent/data) Folder to hold state",
Destination: &AgentConfig.DataDir, Destination: &AgentConfig.DataDir,
...@@ -253,7 +253,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command { ...@@ -253,7 +253,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
NodeTaints, NodeTaints,
ImageCredProvBinDirFlag, ImageCredProvBinDirFlag,
ImageCredProvConfigFlag, ImageCredProvConfigFlag,
&SELinuxFlag, SELinuxFlag,
LBServerPortFlag, LBServerPortFlag,
ProtectKernelDefaultsFlag, ProtectKernelDefaultsFlag,
CRIEndpointFlag, CRIEndpointFlag,
...@@ -270,7 +270,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command { ...@@ -270,7 +270,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
ExtraKubeletArgs, ExtraKubeletArgs,
ExtraKubeProxyArgs, ExtraKubeProxyArgs,
// Experimental flags // Experimental flags
cli.BoolFlag{ &cli.BoolFlag{
Name: "rootless", Name: "rootless",
Usage: "(experimental) Run rootless", Usage: "(experimental) Run rootless",
Destination: &AgentConfig.Rootless, Destination: &AgentConfig.Rootless,
...@@ -280,7 +280,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command { ...@@ -280,7 +280,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
&DisableSELinuxFlag, &DisableSELinuxFlag,
DockerFlag, DockerFlag,
FlannelFlag, FlannelFlag,
cli.StringFlag{ &cli.StringFlag{
Name: "cluster-secret", Name: "cluster-secret",
Usage: "(deprecated) use --token", Usage: "(deprecated) use --token",
Destination: &AgentConfig.ClusterSecret, Destination: &AgentConfig.ClusterSecret,
......
...@@ -15,7 +15,7 @@ var ( ...@@ -15,7 +15,7 @@ var (
LogFile, LogFile,
AlsoLogToStderr, AlsoLogToStderr,
DataDirFlag, DataDirFlag,
cli.StringSliceFlag{ &cli.StringSliceFlag{
Name: "service,s", 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)", 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, Value: &ServicesList,
......
...@@ -11,7 +11,7 @@ func NewCompletionCommand(action func(*cli.Context) error) cli.Command { ...@@ -11,7 +11,7 @@ func NewCompletionCommand(action func(*cli.Context) error) cli.Command {
UsageText: appName + " completion [SHELL] (valid shells: bash, zsh)", UsageText: appName + " completion [SHELL] (valid shells: bash, zsh)",
Action: action, Action: action,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{ &cli.BoolFlag{
Name: "i", Name: "i",
Usage: "Install source line to rc file", Usage: "Install source line to rc file",
}, },
......
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
var ( var (
// ConfigFlag is here to show to the user, but the actually processing is done by configfileargs before // ConfigFlag is here to show to the user, but the actually processing is done by configfileargs before
// call urfave // call urfave
ConfigFlag = cli.StringFlag{ ConfigFlag = &cli.StringFlag{
Name: "config,c", Name: "config,c",
Usage: "(config) Load configuration from `FILE`", Usage: "(config) Load configuration from `FILE`",
EnvVar: version.ProgramUpper + "_CONFIG_FILE", EnvVar: version.ProgramUpper + "_CONFIG_FILE",
......
...@@ -14,7 +14,7 @@ var EtcdSnapshotFlags = []cli.Flag{ ...@@ -14,7 +14,7 @@ var EtcdSnapshotFlags = []cli.Flag{
ConfigFlag, ConfigFlag,
LogFile, LogFile,
AlsoLogToStderr, AlsoLogToStderr,
cli.StringFlag{ &cli.StringFlag{
Name: "node-name", Name: "node-name",
Usage: "(agent/node) Node name", Usage: "(agent/node) Node name",
EnvVar: version.ProgramUpper + "_NODE_NAME", EnvVar: version.ProgramUpper + "_NODE_NAME",
......
...@@ -21,22 +21,22 @@ type Log struct { ...@@ -21,22 +21,22 @@ type Log struct {
var ( var (
LogConfig Log LogConfig Log
VLevel = cli.IntFlag{ VLevel = &cli.IntFlag{
Name: "v", Name: "v",
Usage: "(logging) Number for the log level verbosity", Usage: "(logging) Number for the log level verbosity",
Destination: &LogConfig.VLevel, Destination: &LogConfig.VLevel,
} }
VModule = cli.StringFlag{ VModule = &cli.StringFlag{
Name: "vmodule", Name: "vmodule",
Usage: "(logging) Comma-separated list of FILE_PATTERN=LOG_LEVEL settings for file-filtered logging", Usage: "(logging) Comma-separated list of FILE_PATTERN=LOG_LEVEL settings for file-filtered logging",
Destination: &LogConfig.VModule, Destination: &LogConfig.VModule,
} }
LogFile = cli.StringFlag{ LogFile = &cli.StringFlag{
Name: "log,l", Name: "log,l",
Usage: "(logging) Log to file", Usage: "(logging) Log to file",
Destination: &LogConfig.LogFile, Destination: &LogConfig.LogFile,
} }
AlsoLogToStderr = cli.BoolFlag{ AlsoLogToStderr = &cli.BoolFlag{
Name: "alsologtostderr", Name: "alsologtostderr",
Usage: "(logging) Log to standard error as well as file (if set)", Usage: "(logging) Log to standard error as well as file (if set)",
Destination: &LogConfig.AlsoLogToStderr, Destination: &LogConfig.AlsoLogToStderr,
......
...@@ -11,13 +11,13 @@ import ( ...@@ -11,13 +11,13 @@ import (
var ( var (
Debug bool Debug bool
DebugFlag = cli.BoolFlag{ DebugFlag = &cli.BoolFlag{
Name: "debug", Name: "debug",
Usage: "(logging) Turn on debug logs", Usage: "(logging) Turn on debug logs",
Destination: &Debug, Destination: &Debug,
EnvVar: version.ProgramUpper + "_DEBUG", EnvVar: version.ProgramUpper + "_DEBUG",
} }
PreferBundledBin = cli.BoolFlag{ PreferBundledBin = &cli.BoolFlag{
Name: "prefer-bundled-bin", Name: "prefer-bundled-bin",
Usage: "(experimental) Prefer bundled userspace binaries over host binaries", Usage: "(experimental) Prefer bundled userspace binaries over host binaries",
} }
...@@ -41,7 +41,7 @@ func NewApp() *cli.App { ...@@ -41,7 +41,7 @@ func NewApp() *cli.App {
} }
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
DebugFlag, DebugFlag,
cli.StringFlag{ &cli.StringFlag{
Name: "data-dir,d", Name: "data-dir,d",
Usage: "(data) Folder to hold state (default: /var/lib/rancher/" + version.Program + " or ${HOME}/.rancher/" + version.Program + " if not root)", Usage: "(data) Folder to hold state (default: /var/lib/rancher/" + version.Program + " or ${HOME}/.rancher/" + version.Program + " if not root)",
}, },
......
...@@ -10,7 +10,7 @@ const SecretsEncryptCommand = "secrets-encrypt" ...@@ -10,7 +10,7 @@ const SecretsEncryptCommand = "secrets-encrypt"
var EncryptFlags = []cli.Flag{ var EncryptFlags = []cli.Flag{
DataDirFlag, DataDirFlag,
ServerToken, ServerToken,
cli.StringFlag{ &cli.StringFlag{
Name: "server, s", Name: "server, s",
Usage: "(cluster) Server to connect to", Usage: "(cluster) Server to connect to",
EnvVar: version.ProgramUpper + "_URL", EnvVar: version.ProgramUpper + "_URL",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment