MCPcopy Index your code
hub / github.com/coder/coder / userOIDCClaims

Method userOIDCClaims

cli/useroidcclaims.go:13–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11)
12
13func (r *RootCmd) userOIDCClaims() *serpent.Command {
14 formatter := cliui.NewOutputFormatter(
15 cliui.ChangeFormatterData(
16 cliui.TableFormat([]claimRow{}, []string{"key", "value"}),
17 func(data any) (any, error) {
18 resp, ok := data.(codersdk.OIDCClaimsResponse)
19 if !ok {
20 return nil, xerrors.Errorf("expected type %T, got %T", resp, data)
21 }
22 rows := make([]claimRow, 0, len(resp.Claims))
23 for k, v := range resp.Claims {
24 rows = append(rows, claimRow{
25 Key: k,
26 Value: fmt.Sprintf("%v", v),
27 })
28 }
29 return rows, nil
30 },
31 ),
32 cliui.JSONFormat(),
33 )
34
35 cmd := &serpent.Command{
36 Use: "oidc-claims",
37 Short: "Display the OIDC claims for the authenticated user.",
38 Long: FormatExamples(
39 Example{
40 Description: "Display your OIDC claims",
41 Command: "coder users oidc-claims",
42 },
43 Example{
44 Description: "Display your OIDC claims as JSON",
45 Command: "coder users oidc-claims -o json",
46 },
47 ),
48 Middleware: serpent.Chain(
49 serpent.RequireNArgs(0),
50 ),
51 Handler: func(inv *serpent.Invocation) error {
52 client, err := r.InitClient(inv)
53 if err != nil {
54 return err
55 }
56
57 resp, err := client.UserOIDCClaims(inv.Context())
58 if err != nil {
59 return xerrors.Errorf("get oidc claims: %w", err)
60 }
61
62 out, err := formatter.Format(inv.Context(), resp)
63 if err != nil {
64 return err
65 }
66
67 _, err = fmt.Fprintln(inv.Stdout, out)
68 return err
69 },
70 }

Callers 1

usersMethod · 0.95

Calls 11

InitClientMethod · 0.95
FormatMethod · 0.95
AttachOptionsMethod · 0.95
NewOutputFormatterFunction · 0.92
ChangeFormatterDataFunction · 0.92
TableFormatFunction · 0.92
JSONFormatFunction · 0.92
FormatExamplesFunction · 0.85
UserOIDCClaimsMethod · 0.80
ContextMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected