MCPcopy Index your code
hub / github.com/docker/docker-agent / newDebugOAuthListCmd

Function newDebugOAuthListCmd

cmd/root/debug_oauth.go:30–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28}
29
30func newDebugOAuthListCmd() *cobra.Command {
31 var jsonOutput bool
32
33 cmd := &cobra.Command{
34 Use: "list",
35 Short: "List all stored OAuth tokens",
36 Args: cobra.NoArgs,
37 RunE: func(cmd *cobra.Command, _ []string) (commandErr error) {
38 ctx := cmd.Context()
39 telemetry.TrackCommand(ctx, "debug", []string{"oauth", "list"})
40 defer func() {
41 telemetry.TrackCommandError(ctx, "debug", []string{"oauth", "list"}, commandErr)
42 }()
43
44 w := cmd.OutOrStdout()
45
46 entries, err := mcp.ListOAuthTokens()
47 if err != nil {
48 return fmt.Errorf("failed to list OAuth tokens: %w", err)
49 }
50
51 if len(entries) == 0 {
52 if jsonOutput {
53 return json.NewEncoder(w).Encode([]any{})
54 }
55 fmt.Fprintln(w, "No OAuth tokens stored.")
56 return nil
57 }
58
59 if jsonOutput {
60 return printOAuthListJSON(w, entries)
61 }
62
63 printOAuthListText(w, entries)
64 return nil
65 },
66 }
67
68 cmd.Flags().BoolVar(&jsonOutput, "json", false, "Output in JSON format")
69
70 return cmd
71}
72
73type oauthListEntry struct {
74 ResourceURL string `json:"resource_url"`

Callers 1

newDebugOAuthCmdFunction · 0.85

Calls 6

TrackCommandFunction · 0.92
TrackCommandErrorFunction · 0.92
ListOAuthTokensFunction · 0.92
printOAuthListJSONFunction · 0.85
printOAuthListTextFunction · 0.85
ContextMethod · 0.80

Tested by

no test coverage detected