From fe3121946231107b737e319b680c9686396b9ce1 Mon Sep 17 00:00:00 2001 From: "vitess-bot[bot]" <108069721+vitess-bot[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 00:07:31 -0500 Subject: [PATCH] [release-18.0] Bypass cobra completion commands so they still function (#14217) (#14234) Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> --- 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 c36dfb8575f..1194b49ec8f 100644 --- a/go/cmd/vtctldclient/command/root.go +++ b/go/cmd/vtctldclient/command/root.go @@ -141,6 +141,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 }