MCPcopy
hub / github.com/cli/cli / IsAuthCheckEnabled

Function IsAuthCheckEnabled

pkg/cmdutil/auth_check.go:41–66  ·  view source on GitHub ↗
(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

39}
40
41func IsAuthCheckEnabled(cmd *cobra.Command) bool {
42 switch cmd.Name() {
43 case "help", cobra.ShellCompRequestCmd, cobra.ShellCompNoDescRequestCmd:
44 return false
45 }
46
47 for c := cmd; c.Parent() != nil; c = c.Parent() {
48 // Check whether any command marked as DisableAuthCheck is set
49 if c.Annotations != nil && c.Annotations[skipAuthCheckAnnotation] == "true" {
50 return false
51 }
52
53 // Check whether any flag marked as DisableAuthCheckFlag is set
54 var skipAuthCheck bool
55 c.Flags().Visit(func(f *pflag.Flag) {
56 if f.Annotations != nil && reflect.DeepEqual(f.Annotations[skipAuthCheckAnnotation], []string{"true"}) {
57 skipAuthCheck = true
58 }
59 })
60 if skipAuthCheck {
61 return false
62 }
63 }
64
65 return true
66}

Callers 4

NewCmdRootFunction · 0.92
TestVerifyCmdAuthChecksFunction · 0.92
Test_IsAuthCheckEnabledFunction · 0.85

Calls 1

NameMethod · 0.65