Skip to content

Commit 58f753c

Browse files
Flags migration: Most pending flags migrated for all binaries (vitessio#18624)
Signed-off-by: Rohit Nayak <[email protected]> Co-authored-by: Claude <[email protected]>
1 parent 884aa5a commit 58f753c

File tree

68 files changed

+908
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+908
-258
lines changed

go/cmd/topo2topo/cli/topo2topo.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"vitess.io/vitess/go/vt/sqlparser"
3030
"vitess.io/vitess/go/vt/topo"
3131
"vitess.io/vitess/go/vt/topo/helpers"
32+
"vitess.io/vitess/go/vt/utils"
3233
)
3334

3435
var (
@@ -60,12 +61,12 @@ It can also be used to compare data between two topologies.`,
6061
func init() {
6162
servenv.MoveFlagsToCobraCommand(Main)
6263

63-
Main.Flags().StringVar(&fromImplementation, "from_implementation", fromImplementation, "topology implementation to copy data from")
64-
Main.Flags().StringVar(&fromServerAddress, "from_server", fromServerAddress, "topology server address to copy data from")
65-
Main.Flags().StringVar(&fromRoot, "from_root", fromRoot, "topology server root to copy data from")
66-
Main.Flags().StringVar(&toImplementation, "to_implementation", toImplementation, "topology implementation to copy data to")
67-
Main.Flags().StringVar(&toServerAddress, "to_server", toServerAddress, "topology server address to copy data to")
68-
Main.Flags().StringVar(&toRoot, "to_root", toRoot, "topology server root to copy data to")
64+
utils.SetFlagStringVar(Main.Flags(), &fromImplementation, "from-implementation", fromImplementation, "topology implementation to copy data from")
65+
utils.SetFlagStringVar(Main.Flags(), &fromServerAddress, "from-server", fromServerAddress, "topology server address to copy data from")
66+
utils.SetFlagStringVar(Main.Flags(), &fromRoot, "from-root", fromRoot, "topology server root to copy data from")
67+
utils.SetFlagStringVar(Main.Flags(), &toImplementation, "to-implementation", toImplementation, "topology implementation to copy data to")
68+
utils.SetFlagStringVar(Main.Flags(), &toServerAddress, "to-server", toServerAddress, "topology server address to copy data to")
69+
utils.SetFlagStringVar(Main.Flags(), &toRoot, "to-root", toRoot, "topology server root to copy data to")
6970
Main.Flags().BoolVar(&compare, "compare", compare, "compares data between topologies")
7071
Main.Flags().BoolVar(&doKeyspaces, "do-keyspaces", doKeyspaces, "copies the keyspace information")
7172
Main.Flags().BoolVar(&doShards, "do-shards", doShards, "copies the shard information")

go/cmd/vtbackup/cli/vtbackup.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,25 @@ func init() {
201201

202202
servenv.MoveFlagsToCobraCommand(Main)
203203

204-
Main.Flags().DurationVar(&minBackupInterval, "min_backup_interval", minBackupInterval, "Only take a new backup if it's been at least this long since the most recent backup.")
205-
Main.Flags().DurationVar(&minRetentionTime, "min_retention_time", minRetentionTime, "Keep each old backup for at least this long before removing it. Set to 0 to disable pruning of old backups.")
206-
Main.Flags().IntVar(&minRetentionCount, "min_retention_count", minRetentionCount, "Always keep at least this many of the most recent backups in this backup storage location, even if some are older than the min_retention_time. This must be at least 1 since a backup must always exist to allow new backups to be made")
207-
Main.Flags().BoolVar(&initialBackup, "initial_backup", initialBackup, "Instead of restoring from backup, initialize an empty database with the provided init-db-sql-file and upload a backup of that for the shard, if the shard has no backups yet. This can be used to seed a brand new shard with an initial, empty backup. If any backups already exist for the shard, this will be considered a successful no-op. This can only be done before the shard exists in topology (i.e. before any tablets are deployed).")
208-
Main.Flags().BoolVar(&allowFirstBackup, "allow_first_backup", allowFirstBackup, "Allow this job to take the first backup of an existing shard.")
209-
Main.Flags().BoolVar(&restartBeforeBackup, "restart_before_backup", restartBeforeBackup, "Perform a mysqld clean/full restart after applying binlogs, but before taking the backup. Only makes sense to work around xtrabackup bugs.")
204+
utils.SetFlagDurationVar(Main.Flags(), &minBackupInterval, "min-backup-interval", minBackupInterval, "Only take a new backup if it's been at least this long since the most recent backup.")
205+
utils.SetFlagDurationVar(Main.Flags(), &minRetentionTime, "min-retention-time", minRetentionTime, "Keep each old backup for at least this long before removing it. Set to 0 to disable pruning of old backups.")
206+
utils.SetFlagIntVar(Main.Flags(), &minRetentionCount, "min-retention-count", minRetentionCount, "Always keep at least this many of the most recent backups in this backup storage location, even if some are older than the min_retention_time. This must be at least 1 since a backup must always exist to allow new backups to be made")
207+
utils.SetFlagBoolVar(Main.Flags(), &initialBackup, "initial-backup", initialBackup, "Instead of restoring from backup, initialize an empty database with the provided init-db-sql-file and upload a backup of that for the shard, if the shard has no backups yet. This can be used to seed a brand new shard with an initial, empty backup. If any backups already exist for the shard, this will be considered a successful no-op. This can only be done before the shard exists in topology (i.e. before any tablets are deployed).")
208+
utils.SetFlagBoolVar(Main.Flags(), &allowFirstBackup, "allow-first-backup", allowFirstBackup, "Allow this job to take the first backup of an existing shard.")
209+
utils.SetFlagBoolVar(Main.Flags(), &restartBeforeBackup, "restart-before-backup", restartBeforeBackup, "Perform a mysqld clean/full restart after applying binlogs, but before taking the backup. Only makes sense to work around xtrabackup bugs.")
210210
Main.Flags().BoolVar(&upgradeSafe, "upgrade-safe", upgradeSafe, "Whether to use innodb_fast_shutdown=0 for the backup so it is safe to use for MySQL upgrades.")
211211

212212
// vttablet-like flags
213213
utils.SetFlagStringVar(Main.Flags(), &initDbNameOverride, "init-db-name-override", initDbNameOverride, "(init parameter) override the name of the db used by vttablet")
214214
utils.SetFlagStringVar(Main.Flags(), &initKeyspace, "init-keyspace", initKeyspace, "(init parameter) keyspace to use for this tablet")
215215
utils.SetFlagStringVar(Main.Flags(), &initShard, "init-shard", initShard, "(init parameter) shard to use for this tablet")
216216
Main.Flags().IntVar(&concurrency, "concurrency", concurrency, "(init restore parameter) how many concurrent files to restore at once")
217-
Main.Flags().StringVar(&incrementalFromPos, "incremental_from_pos", incrementalFromPos, "Position, or name of backup from which to create an incremental backup. Default: empty. If given, then this backup becomes an incremental backup from given position or given backup. If value is 'auto', this backup will be taken from the last successful backup position.")
217+
utils.SetFlagStringVar(Main.Flags(), &incrementalFromPos, "incremental-from-pos", incrementalFromPos, "Position, or name of backup from which to create an incremental backup. Default: empty. If given, then this backup becomes an incremental backup from given position or given backup. If value is 'auto', this backup will be taken from the last successful backup position.")
218218

219219
// mysqlctld-like flags
220220
utils.SetFlagIntVar(Main.Flags(), &mysqlPort, "mysql-port", mysqlPort, "MySQL port")
221221
utils.SetFlagStringVar(Main.Flags(), &mysqlSocket, "mysql-socket", mysqlSocket, "Path to the mysqld socket file")
222-
Main.Flags().DurationVar(&mysqlTimeout, "mysql_timeout", mysqlTimeout, "how long to wait for mysqld startup")
222+
utils.SetFlagDurationVar(Main.Flags(), &mysqlTimeout, "mysql-timeout", mysqlTimeout, "how long to wait for mysqld startup")
223223
Main.Flags().DurationVar(&mysqlShutdownTimeout, "mysql-shutdown-timeout", mysqlShutdownTimeout, "how long to wait for mysqld shutdown")
224224
utils.SetFlagStringVar(Main.Flags(), &initDBSQLFile, "init-db-sql-file", initDBSQLFile, "path to .sql file to run after mysql_install_db")
225225
Main.Flags().BoolVar(&detachedMode, "detach", detachedMode, "detached mode - run backups detached from the terminal")

go/cmd/vtbench/cli/vtbench.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"vitess.io/vitess/go/vt/grpccommon"
3131
"vitess.io/vitess/go/vt/logutil"
3232
"vitess.io/vitess/go/vt/servenv"
33+
"vitess.io/vitess/go/vt/utils"
3334
"vitess.io/vitess/go/vtbench"
3435

3536
// Import and register the gRPC vtgateconn client
@@ -139,7 +140,7 @@ func init() {
139140

140141
Main.Flags().StringVar(&host, "host", host, "VTGate host(s) in the form 'host1,host2,...'")
141142
Main.Flags().IntVar(&port, "port", port, "VTGate port")
142-
Main.Flags().StringVar(&unixSocket, "unix_socket", unixSocket, "VTGate unix socket")
143+
utils.SetFlagStringVar(Main.Flags(), &unixSocket, "unix-socket", unixSocket, "VTGate unix socket")
143144
Main.Flags().StringVar(&protocol, "protocol", protocol, "Client protocol, either mysql (default), grpc-vtgate, or grpc-vttablet")
144145
Main.Flags().StringVar(&user, "user", user, "Username to connect using mysql (password comes from the db-credentials-file)")
145146
Main.Flags().StringVar(&db, "db", db, "Database name to use when connecting / running the queries (e.g. @replica, keyspace, keyspace/shard etc)")

go/cmd/vtclient/cli/vtclient.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"vitess.io/vitess/go/vt/logutil"
4040
"vitess.io/vitess/go/vt/servenv"
4141
"vitess.io/vitess/go/vt/sqlparser"
42+
"vitess.io/vitess/go/vt/utils"
4243
"vitess.io/vitess/go/vt/vitessdriver"
4344
"vitess.io/vitess/go/vt/vterrors"
4445
"vitess.io/vitess/go/vt/vtgate/vtgateconn"
@@ -92,16 +93,16 @@ func InitializeFlags() {
9293
Main.Flags().BoolVar(&jsonOutput, "json", jsonOutput, "Output JSON instead of human-readable table")
9394
Main.Flags().IntVar(&parallel, "parallel", parallel, "DMLs only: Number of threads executing the same query in parallel. Useful for simple load testing.")
9495
Main.Flags().IntVar(&count, "count", count, "DMLs only: Number of times each thread executes the query. Useful for simple, sustained load testing.")
95-
Main.Flags().IntVar(&minSeqID, "min_sequence_id", minSeqID, "min sequence ID to generate. When max_sequence_id > min_sequence_id, for each query, a number is generated in [min_sequence_id, max_sequence_id) and attached to the end of the bind variables.")
96-
Main.Flags().IntVar(&maxSeqID, "max_sequence_id", maxSeqID, "max sequence ID.")
97-
Main.Flags().BoolVar(&useRandom, "use_random_sequence", useRandom, "use random sequence for generating [min_sequence_id, max_sequence_id)")
96+
utils.SetFlagIntVar(Main.Flags(), &minSeqID, "min-sequence-id", minSeqID, "min sequence ID to generate. When max-sequence-id > min-sequence-id, for each query, a number is generated in [min-sequence-id, max-sequence-id) and attached to the end of the bind variables.")
97+
utils.SetFlagIntVar(Main.Flags(), &maxSeqID, "max-sequence-id", maxSeqID, "max sequence ID.")
98+
utils.SetFlagBoolVar(Main.Flags(), &useRandom, "use-random-sequence", useRandom, "use random sequence for generating [min-sequence-id, max-sequence-id)")
9899
Main.Flags().IntVar(&qps, "qps", qps, "queries per second to throttle each thread at.")
99100

100101
acl.RegisterFlags(Main.Flags())
101102
grpccommon.RegisterFlags(Main.Flags())
102103
servenv.RegisterMySQLServerFlags(Main.Flags())
103104

104-
bindVariables = newBindvars(Main.Flags(), "bind_variables", "bind variables as a json list")
105+
bindVariables = newBindvars(Main.Flags(), "bind-variables", "bind variables as a json list")
105106
}
106107

107108
type bindvars []any
@@ -146,7 +147,7 @@ func (bv *bindvars) Type() string {
146147

147148
func newBindvars(fs *pflag.FlagSet, name, usage string) *bindvars {
148149
var bv bindvars
149-
fs.Var(&bv, name, usage)
150+
utils.SetFlagVar(fs, &bv, name, usage)
150151
return &bv
151152
}
152153

go/cmd/vtclient/cli/vtclient_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func TestVtclient(t *testing.T) {
9191
args: []string{"SELECT * FROM table1"},
9292
},
9393
{
94-
args: []string{"--target", "@primary", "--bind_variables", `[ 1, 100 ]`,
94+
args: []string{"--target", "@primary", "--bind-variables", `[ 1, 100 ]`,
9595
"INSERT INTO table1 (id, i) VALUES (:v1, :v2)"},
9696
rowsAffected: 1,
9797
},
@@ -106,7 +106,7 @@ func TestVtclient(t *testing.T) {
106106
rowsAffected: 1,
107107
},
108108
{
109-
args: []string{"--target", "@primary", "--bind_variables", `[ 1 ]`,
109+
args: []string{"--target", "@primary", "--bind-variables", `[ 1 ]`,
110110
"DELETE FROM table1 WHERE id = :v1"},
111111
rowsAffected: 1,
112112
},

go/cmd/vtctlclient/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"vitess.io/vitess/go/vt/log"
3333
"vitess.io/vitess/go/vt/logutil"
3434
"vitess.io/vitess/go/vt/servenv"
35+
"vitess.io/vitess/go/vt/utils"
3536
"vitess.io/vitess/go/vt/vtctl/vtctlclient"
3637

3738
logutilpb "vitess.io/vitess/go/vt/proto/logutil"
@@ -47,7 +48,7 @@ var (
4748

4849
func init() {
4950
servenv.OnParse(func(fs *pflag.FlagSet) {
50-
fs.DurationVar(&actionTimeout, "action_timeout", actionTimeout, "timeout for the total command")
51+
utils.SetFlagDurationVar(fs, &actionTimeout, "action-timeout", actionTimeout, "timeout for the total command")
5152
fs.StringVar(&server, "server", server, "server to use for connection")
5253

5354
acl.RegisterFlags(fs)

go/cmd/vtctldclient/command/root.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"vitess.io/vitess/go/vt/logutil"
3333
"vitess.io/vitess/go/vt/servenv"
3434
"vitess.io/vitess/go/vt/topo"
35+
"vitess.io/vitess/go/vt/utils"
3536
"vitess.io/vitess/go/vt/vtctl/grpcvtctldserver"
3637
"vitess.io/vitess/go/vt/vtctl/localvtctldclient"
3738
"vitess.io/vitess/go/vt/vtctl/vtctldclient"
@@ -223,7 +224,7 @@ func getClientForCommand(cmd *cobra.Command) (vtctldclient.VtctldClient, error)
223224

224225
func init() {
225226
Root.PersistentFlags().StringVar(&server, "server", "", "server to use for the connection (required)")
226-
Root.PersistentFlags().DurationVar(&actionTimeout, "action_timeout", time.Hour, "timeout to use for the command")
227+
utils.SetFlagDurationVar(Root.PersistentFlags(), &actionTimeout, "action-timeout", time.Hour, "timeout to use for the command")
227228
Root.PersistentFlags().BoolVar(&compactOutput, "compact", false, "use compact format for otherwise verbose outputs")
228229
Root.PersistentFlags().StringVar(&topoOptions.implementation, "topo-implementation", topoOptions.implementation, "the topology implementation to use")
229230
Root.PersistentFlags().StringSliceVar(&topoOptions.globalServerAddresses, "topo-global-server-address", topoOptions.globalServerAddresses, "the address of the global topology server(s)")

go/cmd/vtgate/cli/plugin_auth_clientcert.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ package cli
2020

2121
import (
2222
"vitess.io/vitess/go/mysql"
23+
"vitess.io/vitess/go/vt/utils"
2324
"vitess.io/vitess/go/vt/vtgate"
2425
)
2526

2627
var clientcertAuthMethod string
2728

2829
func init() {
29-
Main.Flags().StringVar(&clientcertAuthMethod, "mysql_clientcert_auth_method", string(mysql.MysqlClearPassword), "client-side authentication method to use. Supported values: mysql_clear_password, dialog.")
30+
utils.SetFlagStringVar(Main.Flags(), &clientcertAuthMethod, "mysql-clientcert-auth-method", string(mysql.MysqlClearPassword), "client-side authentication method to use. Supported values: mysql_clear_password, dialog.")
3031

3132
vtgate.RegisterPluginInitializer(func() {
3233
mysql.InitAuthServerClientCert(clientcertAuthMethod, vtgate.GetMysqlServerSSLCA())

go/cmd/vtgate/cli/plugin_auth_ldap.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package cli
2121
import (
2222
"vitess.io/vitess/go/mysql"
2323
"vitess.io/vitess/go/mysql/ldapauthserver"
24+
"vitess.io/vitess/go/vt/utils"
2425
"vitess.io/vitess/go/vt/vtgate"
2526
)
2627

@@ -31,9 +32,9 @@ var (
3132
)
3233

3334
func init() {
34-
Main.Flags().StringVar(&ldapAuthConfigFile, "mysql_ldap_auth_config_file", "", "JSON File from which to read LDAP server config.")
35-
Main.Flags().StringVar(&ldapAuthConfigString, "mysql_ldap_auth_config_string", "", "JSON representation of LDAP server config.")
36-
Main.Flags().StringVar(&ldapAuthMethod, "mysql_ldap_auth_method", string(mysql.MysqlClearPassword), "client-side authentication method to use. Supported values: mysql_clear_password, dialog.")
35+
utils.SetFlagStringVar(Main.Flags(), &ldapAuthConfigFile, "mysql-ldap-auth-config-file", "", "JSON File from which to read LDAP server config.")
36+
utils.SetFlagStringVar(Main.Flags(), &ldapAuthConfigString, "mysql-ldap-auth-config-string", "", "JSON representation of LDAP server config.")
37+
utils.SetFlagStringVar(Main.Flags(), &ldapAuthMethod, "mysql-ldap-auth-method", string(mysql.MysqlClearPassword), "client-side authentication method to use. Supported values: mysql_clear_password, dialog.")
3738

3839
vtgate.RegisterPluginInitializer(func() { ldapauthserver.Init(ldapAuthConfigFile, ldapAuthConfigString, ldapAuthMethod) })
3940
}

go/cmd/vtgate/cli/plugin_auth_static.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"time"
2323

2424
"vitess.io/vitess/go/mysql"
25+
"vitess.io/vitess/go/vt/utils"
2526
"vitess.io/vitess/go/vt/vtgate"
2627
)
2728

@@ -32,9 +33,9 @@ var (
3233
)
3334

3435
func init() {
35-
Main.Flags().StringVar(&mysqlAuthServerStaticFile, "mysql_auth_server_static_file", "", "JSON File to read the users/passwords from.")
36-
Main.Flags().StringVar(&mysqlAuthServerStaticString, "mysql_auth_server_static_string", "", "JSON representation of the users/passwords config.")
37-
Main.Flags().DurationVar(&mysqlAuthServerStaticReloadInterval, "mysql_auth_static_reload_interval", 0, "Ticker to reload credentials")
36+
utils.SetFlagStringVar(Main.Flags(), &mysqlAuthServerStaticFile, "mysql-auth-server-static-file", "", "JSON File to read the users/passwords from.")
37+
utils.SetFlagStringVar(Main.Flags(), &mysqlAuthServerStaticString, "mysql-auth-server-static-string", "", "JSON representation of the users/passwords config.")
38+
utils.SetFlagDurationVar(Main.Flags(), &mysqlAuthServerStaticReloadInterval, "mysql-auth-static-reload-interval", 0, "Ticker to reload credentials")
3839

3940
vtgate.RegisterPluginInitializer(func() {
4041
mysql.InitAuthServerStatic(mysqlAuthServerStaticFile, mysqlAuthServerStaticString, mysqlAuthServerStaticReloadInterval)

0 commit comments

Comments
 (0)