Skip to content
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
2 changes: 1 addition & 1 deletion go/cmd/mysqlctl/command/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func commandStart(cmd *cobra.Command, args []string) error {

func init() {
utils.SetFlagDurationVar(Start.Flags(), &startArgs.WaitTime, "wait-time", startArgs.WaitTime, "How long to wait for mysqld startup.")
Start.Flags().Var(&startArgs.MySQLdArgs, "mysqld_args", "List of comma-separated flags to pass additionally to mysqld.")
Start.Flags().Var(&startArgs.MySQLdArgs, "mysqld-args", "List of comma-separated flags to pass additionally to mysqld.")

Root.AddCommand(Start)
}
3 changes: 3 additions & 0 deletions go/cmd/mysqlctl/mysqlctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ package main
import (
"vitess.io/vitess/go/cmd/mysqlctl/command"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
command.Root.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)

if err := command.Root.Execute(); err != nil {
log.Exit(err)
}
Expand Down
3 changes: 3 additions & 0 deletions go/cmd/mysqlctld/mysqlctld.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ package main
import (
"vitess.io/vitess/go/cmd/mysqlctld/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)

if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/rulesctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
vtlog "vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/utils"
)

func main() {
rootCmd := cmd.Main()
rootCmd.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
vtlog.RegisterFlags(rootCmd.PersistentFlags())
logutil.RegisterFlags(rootCmd.PersistentFlags())
acl.RegisterFlags(rootCmd.PersistentFlags())
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/topo2topo/topo2topo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"vitess.io/vitess/go/cmd/topo2topo/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.RecoverAll()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exitf("%s", err)
}
Expand Down
3 changes: 3 additions & 0 deletions go/cmd/vtaclcheck/cli/vtactlcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"vitess.io/vitess/go/acl"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/utils"
"vitess.io/vitess/go/vt/vtaclcheck"
)

Expand Down Expand Up @@ -58,6 +59,8 @@ func run(cmd *cobra.Command, args []string) error {
}

func init() {
Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)

servenv.MoveFlagsToCobraCommand(Main)

Main.Flags().StringVar(&aclFile, "acl-file", aclFile, "The path of the JSON ACL file to check")
Expand Down
1 change: 1 addition & 0 deletions go/cmd/vtadmin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func registerFlags() {
func main() {
registerFlags()

rootCmd.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtbackup/vtbackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"vitess.io/vitess/go/cmd/vtbackup/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Error(err)
exit.Return(1)
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtbench/vtbench.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"vitess.io/vitess/go/cmd/vtbench/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
3 changes: 3 additions & 0 deletions go/cmd/vtclient/vtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ package main
import (
"vitess.io/vitess/go/cmd/vtclient/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
cli.InitializeFlags()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtcombo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import (
"vitess.io/vitess/go/cmd/vtcombo/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Error(err)
exit.Return(1)
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtctl/vtctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ func init() {
fs.BoolVar(&detachedMode, "detach", detachedMode, "detached mode - run vtcl detached from the terminal")

acl.RegisterFlags(fs)

fs.SetNormalizeFunc(utils.NormalizeUnderscoresToDashes)
})
}

Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtctlclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func init() {
fs.StringVar(&server, "server", server, "server to use for connection")

acl.RegisterFlags(fs)

fs.SetNormalizeFunc(utils.NormalizeUnderscoresToDashes)
})
}

Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtctld/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ package main
import (
"vitess.io/vitess/go/cmd/vtctld/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtctldclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"vitess.io/vitess/go/vt/vttablet/tmclient"

_flag "vitess.io/vitess/go/internal/flag"
flagUtils "vitess.io/vitess/go/vt/utils"
)

func main() {
Expand All @@ -55,6 +56,7 @@ func main() {
// hack to get rid of an "ERROR: logging before flag.Parse"
_flag.TrickGlog()

command.Root.SetGlobalNormalizationFunc(flagUtils.NormalizeUnderscoresToDashes)
// back to your regularly scheduled cobra programming
if err := command.Root.Execute(); err != nil {
log.Error(err)
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtexplain/vtexplain.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import (

"vitess.io/vitess/go/cmd/vtexplain/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.RecoverAll()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
fmt.Printf("ERROR: %s\n", err)
exit.Return(1)
Expand Down
4 changes: 1 addition & 3 deletions go/cmd/vtgate/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,5 @@ func init() {
Main.Flags().StringVar(&plannerName, "planner-version", plannerName, "Sets the default planner to use when the session has not changed it. Valid values are: Gen4, Gen4Greedy, Gen4Left2Right")

// Support both variants until v25
// Main.MarkFlagRequired("tablet-types-to-wait")
Main.MarkFlagsOneRequired("tablet-types-to-wait", "tablet_types_to_wait")

Main.MarkFlagsOneRequired("tablet-types-to-wait")
}
2 changes: 2 additions & 0 deletions go/cmd/vtgate/vtgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ package main
import (
"vitess.io/vitess/go/cmd/vtgate/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtgateclienttest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"vitess.io/vitess/go/cmd/vtgateclienttest/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exitf("%s", err)
}
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtorc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ package main
import (
"vitess.io/vitess/go/cmd/vtorc/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

// main is the application's entry point. It will spawn an HTTP interface.
func main() {
// TODO: viperutil.BindFlags()

cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
20 changes: 10 additions & 10 deletions go/cmd/vttablet/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/topo/memorytopo"
"vitess.io/vitess/go/vt/utils"
)

// TestRunFailsToStartTabletManager tests the code path in 'run' where we fail to start the TabletManager
Expand All @@ -43,15 +42,16 @@ func TestRunFailsToStartTabletManager(t *testing.T) {
os.Args = append([]string{}, args...)
})

flags := make(map[string]string)
utils.SetFlagVariantsForTests(flags, "--topo-implementation", "test")
utils.SetFlagVariantsForTests(flags, "--topo-global-server-address", "localhost")
utils.SetFlagVariantsForTests(flags, "--topo-global-root", "cell")
utils.SetFlagVariantsForTests(flags, "--db-host", "localhost")
utils.SetFlagVariantsForTests(flags, "--db-port", "3306")
utils.SetFlagVariantsForTests(flags, "--init-keyspace", "ks")
utils.SetFlagVariantsForTests(flags, "--init-shard", "0")
utils.SetFlagVariantsForTests(flags, "--init-tablet-type", "replica")
flags := map[string]string{
"--topo-implementation": "test",
"--topo-global-server-address": "localhost",
"--topo-global-root": "cell",
"--db-host": "localhost",
"--db-port": "3306",
"--init-keyspace": "ks",
"--init-shard": "0",
"--init-tablet-type": "replica",
}

var flagArgs []string
for flag, value := range flags {
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vttablet/vttablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ package main
import (
"vitess.io/vitess/go/cmd/vttablet/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
cli.Main.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
37 changes: 18 additions & 19 deletions go/cmd/vttestserver/cli/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/tlstest"
"vitess.io/vitess/go/vt/utils"
"vitess.io/vitess/go/vt/vtctl/vtctlclient"
"vitess.io/vitess/go/vt/vttest"

Expand Down Expand Up @@ -191,7 +190,7 @@ func TestNoScatter(t *testing.T) {
conf := config
defer resetConfig(conf)

cluster, err := startCluster(utils.GetFlagVariantForTests("--no-scatter"))
cluster, err := startCluster("--no-scatter")
require.NoError(t, err)
defer cluster.TearDown()

Expand Down Expand Up @@ -303,14 +302,14 @@ func TestMtlsAuth(t *testing.T) {
// When cluster starts it will apply SQL and VSchema migrations in the configured schema-dir folder
// With mtls authorization enabled, the authorized CN must match the certificate's CN
cluster, err := startCluster(
utils.GetFlagVariantForTests("--grpc-auth-mode")+"=mtls",
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--grpc-key"), key),
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--grpc-cert"), cert),
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--grpc-ca"), caCert),
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--vtctld-grpc-key"), clientKey),
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--vtctld-grpc-cert"), clientCert),
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--vtctld-grpc-ca"), caCert),
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--grpc-auth-mtls-allowed-substrings"), "CN=ClientApp"))
"--grpc-auth-mode=mtls",
fmt.Sprintf("%s=%s", "--grpc-key", key),
fmt.Sprintf("%s=%s", "--grpc-cert", cert),
fmt.Sprintf("%s=%s", "--grpc-ca", caCert),
fmt.Sprintf("%s=%s", "--vtctld-grpc-key", clientKey),
fmt.Sprintf("%s=%s", "--vtctld-grpc-cert", clientCert),
fmt.Sprintf("%s=%s", "--vtctld-grpc-ca", caCert),
fmt.Sprintf("%s=%s", "--grpc-auth-mtls-allowed-substrings", "CN=ClientApp"))
require.NoError(t, err)
defer func() {
cluster.PersistentMode = false // Cleanup the tmpdir as we're done
Expand Down Expand Up @@ -345,13 +344,13 @@ func TestMtlsAuthUnauthorizedFails(t *testing.T) {
// For mtls authorization failure by providing a client certificate with different CN thant the
// authorized in the configuration
cluster, err := startCluster(
utils.GetFlagVariantForTests("--grpc-auth-mode")+"=mtls",
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--grpc-key"), key),
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--grpc-cert"), cert),
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--grpc-ca"), caCert),
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--vtctld-grpc-key"), clientKey),
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--vtctld-grpc-cert"), clientCert),
fmt.Sprintf("%s=%s", utils.GetFlagVariantForTests("--vtctld-grpc-ca"), caCert),
"--grpc-auth-mode=mtls",
fmt.Sprintf("%s=%s", "--grpc-key", key),
fmt.Sprintf("%s=%s", "--grpc-cert", cert),
fmt.Sprintf("%s=%s", "--grpc-ca", caCert),
fmt.Sprintf("%s=%s", "--vtctld-grpc-key", clientKey),
fmt.Sprintf("%s=%s", "--vtctld-grpc-cert", clientCert),
fmt.Sprintf("%s=%s", "--vtctld-grpc-ca", caCert),
fmt.Sprintf("--grpc-auth-mtls-allowed-substrings=%s", "CN=ClientApp"))
defer cluster.TearDown()

Expand All @@ -376,8 +375,8 @@ var clusterKeyspaces = []string{

func startCluster(flags ...string) (cluster vttest.LocalCluster, err error) {
args := []string{"vttestserver"}
schemaDirArg := utils.GetFlagVariantForTests("--schema-dir") + "=data/schema"
tabletHostname := fmt.Sprintf("%s=localhost", utils.GetFlagVariantForTests("--tablet-hostname"))
schemaDirArg := "--schema-dir=data/schema"
tabletHostname := fmt.Sprintf("%s=localhost", "--tablet-hostname")
keyspaceArg := "--keyspaces=" + strings.Join(clusterKeyspaces, ",")
numShardsArg := "--num-shards=2,2"
vschemaDDLAuthorizedUsers := "--vschema-ddl-authorized-users=%"
Expand Down
5 changes: 4 additions & 1 deletion go/cmd/vttestserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ package main
import (
"vitess.io/vitess/go/cmd/vttestserver/cli"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/utils"
)

func main() {
if err := cli.New().Execute(); err != nil {
cmd := cli.New()
cmd.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
if err := cmd.Execute(); err != nil {
log.Fatal(err)
}
}
2 changes: 2 additions & 0 deletions go/cmd/vttlstest/vttlstest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ import (
"vitess.io/vitess/go/cmd/vttlstest/cli"
"vitess.io/vitess/go/exit"
"vitess.io/vitess/go/vt/logutil"
"vitess.io/vitess/go/vt/utils"
)

func main() {
defer exit.Recover()
defer logutil.Flush()

cli.Root.SetGlobalNormalizationFunc(utils.NormalizeUnderscoresToDashes)
cobra.CheckErr(cli.Root.Execute())
}
Loading
Loading