Skip to content

Commit

Permalink
Fix vtclient vtgate missing flags (specifically --grpc_*) (#17800)
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Johnson <[email protected]>
Co-authored-by: Kyle Johnson <[email protected]>
  • Loading branch information
corbantek and Kyle Johnson authored Feb 21, 2025
1 parent db77d81 commit 0a6f982
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go/cmd/vtclient/cli/vtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var (
seqChan = make(chan int, 10)
)

func init() {
func InitializeFlags() {
servenv.MoveFlagsToCobraCommand(Main)

Main.Flags().StringVar(&server, "server", server, "vtgate server to connect to")
Expand Down
2 changes: 2 additions & 0 deletions go/cmd/vtclient/cli/vtclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ func TestVtclient(t *testing.T) {
},
}

// initialize the vtclient flags before running any commands
InitializeFlags()
for _, q := range queries {
// Run main function directly and not as external process. To achieve this,
// overwrite os.Args which is used by pflag.Parse().
Expand Down
1 change: 1 addition & 0 deletions go/cmd/vtclient/vtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
)

func main() {
cli.InitializeFlags()
if err := cli.Main.Execute(); err != nil {
log.Exit(err)
}
Expand Down
4 changes: 2 additions & 2 deletions go/vt/servenv/servenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func ParseFlagsForTests(cmd string) {
// the given cobra command, then copies over the glog flags that otherwise
// require manual transferring.
func MoveFlagsToCobraCommand(cmd *cobra.Command) {
moveFlags(cmd.Use, cmd.Flags())
moveFlags(cmd.Name(), cmd.Flags())
}

// MovePersistentFlagsToCobraCommand functions exactly like MoveFlagsToCobraCommand,
Expand All @@ -347,7 +347,7 @@ func MoveFlagsToCobraCommand(cmd *cobra.Command) {
// Useful for transferring flags to a parent command whose subcommands should
// inherit the servenv-registered flags.
func MovePersistentFlagsToCobraCommand(cmd *cobra.Command) {
moveFlags(cmd.Use, cmd.PersistentFlags())
moveFlags(cmd.Name(), cmd.PersistentFlags())
}

func moveFlags(name string, fs *pflag.FlagSet) {
Expand Down

0 comments on commit 0a6f982

Please sign in to comment.