From 595ab85f8cf4774041dbea6ebc1a22c0fdd0944d Mon Sep 17 00:00:00 2001 From: "vitess-bot[bot]" <108069721+vitess-bot[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 21:13:10 -0400 Subject: [PATCH] Bypass cobra completion commands so they still function (#14217) --- go/cmd/vtctldclient/command/root.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/go/cmd/vtctldclient/command/root.go b/go/cmd/vtctldclient/command/root.go index 2b400d5878d..53154df14d9 100644 --- a/go/cmd/vtctldclient/command/root.go +++ b/go/cmd/vtctldclient/command/root.go @@ -136,6 +136,13 @@ func getClientForCommand(cmd *cobra.Command) (vtctldclient.VtctldClient, error) } } + // Reserved cobra commands for shell completion that we don't want to fail + // here. + switch { + case cmd.Name() == "__complete", cmd.Parent() != nil && cmd.Parent().Name() == "completion": + return nil, nil + } + if VtctldClientProtocol != "local" && server == "" { return nil, errNoServer }