-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[vtctldclient] Add legacy shim #8284
Conversation
Signed-off-by: Andrew Mason <amason@slack-corp.com>
This turns the output from: ``` ❯ vtctlclient -server "localhost:15999" ListAllTablets -h Usage: ListAllTablets <cell name1>, <cell name2>, ... Lists all tablets in an awk-friendly way. ListAllTablets Error: rpc error: code = Unknown desc = flag: help requested E0528 19:52:46.564223 77260 main.go:76] remote error: rpc error: code = Unknown desc = flag: help requested ❯ echo $? 1 ``` into: ``` ❯ vtctlclient -server "localhost:15999" ListAllTablets -h Usage: ListAllTablets <cell name1>, <cell name2>, ... Lists all tablets in an awk-friendly way. ❯ echo $? 0 ``` Signed-off-by: Andrew Mason <amason@slack-corp.com>
This is admittedly pretty hacky, and I had to spend a lot of time messing around with cobra to make this behavior correctly. But, it works! Signed-off-by: Andrew Mason <amason@slack-corp.com>
Also remove the custom help func hack, because it turns out we don't actually need it (thank goodness) Signed-off-by: Andrew Mason <amason@slack-corp.com>
@@ -67,6 +67,10 @@ func main() { | |||
logutil.LogEvent(logger, e) | |||
}) | |||
if err != nil { | |||
if strings.Contains(err.Error(), "flag: help requested") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This turns:
❯ vtctlclient -server "localhost:15999" ListAllTablets -h
Usage: ListAllTablets <cell name1>, <cell name2>, ...
Lists all tablets in an awk-friendly way.
ListAllTablets Error: rpc error: code = Unknown desc = flag: help requested
E0528 19:52:46.564223 77260 main.go:76] remote error: rpc error: code = Unknown desc = flag: help requested
❯ echo $?
1
Into
❯ vtctlclient -server "localhost:15999" ListAllTablets -h
Usage: ListAllTablets <cell name1>, <cell name2>, ...
Lists all tablets in an awk-friendly way.
❯ echo $?
0
@@ -0,0 +1,23 @@ | |||
/* | |||
Copyright 2020 The Vitess Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit: copyright is the wrong year
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More like copywrong, amirite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahah i copied this file from vtctlclient
|
||
package main | ||
|
||
// Imports and register the gRPC vtctl client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another tiny nit: "register" -> "registers"
Signed-off-by: Andrew Mason <amason@slack-corp.com>
…y_shim [vtctldclient] Add legacy shim
Description
This PR adds a shim to the new vtctldclient to allow running legacy vtctl commands that have not yet been migrated. The intention here is to allow users to start updating any scripts they have now (going from
vtctlclient [args ...]
tovtctldclient LegacyVtctlCommand -- [args ...]
), and then dropping the old client should be ideally a no-op, or at least far less painful.Examples!
client-side help
server-side help showing available commands
Getting tablets, both ways
Getting per-command server-side help, using legacy commands that take flags, etc
Related Issue(s)
#7058
Checklist
Deployment Notes