From f2d9fca63059577c8514253a803233b8dfec6d75 Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Mon, 9 Oct 2023 18:43:00 -0400 Subject: [PATCH] Bypass cobra completion commands so they still function Signed-off-by: Andrew Mason --- 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 }