From 6cf6bb4a44453f0f03bd987b73ea1c8e734a6a3f Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 25 Aug 2021 01:35:49 +0700 Subject: [PATCH] Disable auth for cobra shell request completion hidden commands Those hidden command are used by the shell completion scripts, but they are not disabled auth check. Thus, the shell completion does not work even the completion setup was done properly. Fixes #4188 --- pkg/cmdutil/auth_check.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/cmdutil/auth_check.go b/pkg/cmdutil/auth_check.go index ab536f6b2..df40390fd 100644 --- a/pkg/cmdutil/auth_check.go +++ b/pkg/cmdutil/auth_check.go @@ -34,9 +34,11 @@ func CheckAuth(cfg config.Config) bool { } func IsAuthCheckEnabled(cmd *cobra.Command) bool { - if cmd.Name() == "help" { + switch cmd.Name() { + case "help", cobra.ShellCompRequestCmd, cobra.ShellCompNoDescRequestCmd: return false } + for c := cmd; c.Parent() != nil; c = c.Parent() { if c.Annotations != nil && c.Annotations["skipAuthCheck"] == "true" { return false