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

Method provisionerKeysList

enterprise/cli/provisionerkeys.go:96–149  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94}
95
96func (r *RootCmd) provisionerKeysList() *serpent.Command {
97 var (
98 orgContext = agpl.NewOrganizationContext()
99 formatter = cliui.NewOutputFormatter(
100 cliui.TableFormat([]codersdk.ProvisionerKey{}, []string{"created at", "name", "tags"}),
101 cliui.JSONFormat(),
102 )
103 )
104
105 cmd := &serpent.Command{
106 Use: "list",
107 Short: "List provisioner keys in an organization",
108 Aliases: []string{"ls"},
109 Middleware: serpent.Chain(
110 serpent.RequireNArgs(0),
111 ),
112 Handler: func(inv *serpent.Invocation) error {
113 ctx := inv.Context()
114 client, err := r.InitClient(inv)
115 if err != nil {
116 return err
117 }
118
119 org, err := orgContext.Selected(inv, client)
120 if err != nil {
121 return xerrors.Errorf("current organization: %w", err)
122 }
123
124 keys, err := client.ListProvisionerKeys(ctx, org.ID)
125 if err != nil {
126 return xerrors.Errorf("list provisioner keys: %w", err)
127 }
128
129 out, err := formatter.Format(inv.Context(), keys)
130 if err != nil {
131 return xerrors.Errorf("display provisioner keys: %w", err)
132 }
133
134 if out == "" {
135 cliui.Infof(inv.Stderr, "No provisioner keys found.")
136 return nil
137 }
138
139 _, _ = fmt.Fprintln(inv.Stdout, out)
140
141 return nil
142 },
143 }
144
145 orgContext.AttachOptions(cmd)
146 formatter.AttachOptions(&cmd.Options)
147
148 return cmd
149}
150
151func (r *RootCmd) provisionerKeysDelete() *serpent.Command {
152 orgContext := agpl.NewOrganizationContext()

Callers 1

provisionerKeysMethod · 0.95

Calls 11

InitClientMethod · 0.95
NewOutputFormatterFunction · 0.92
TableFormatFunction · 0.92
JSONFormatFunction · 0.92
InfofFunction · 0.92
SelectedMethod · 0.80
ListProvisionerKeysMethod · 0.80
ContextMethod · 0.65
FormatMethod · 0.65
AttachOptionsMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected