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

Method deleteProxy

enterprise/cli/workspaceproxy.go:192–235  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

190}
191
192func (r *RootCmd) deleteProxy() *serpent.Command {
193 cmd := &serpent.Command{
194 Use: "delete <name|id>",
195 Short: "Delete a workspace proxy",
196 Options: serpent.OptionSet{
197 cliui.SkipPromptOption(),
198 },
199 Middleware: serpent.Chain(
200 serpent.RequireNArgs(1),
201 ),
202 Handler: func(inv *serpent.Invocation) error {
203 ctx := inv.Context()
204 client, err := r.InitClient(inv)
205 if err != nil {
206 return err
207 }
208
209 wsproxy, err := client.WorkspaceProxyByName(ctx, inv.Args[0])
210 if err != nil {
211 return xerrors.Errorf("fetch workspace proxy %q: %w", inv.Args[0], err)
212 }
213
214 // Confirm deletion of the template.
215 _, err = cliui.Prompt(inv, cliui.PromptOptions{
216 Text: fmt.Sprintf("Delete this workspace proxy: %s?", pretty.Sprint(cliui.DefaultStyles.Code, wsproxy.DisplayName)),
217 IsConfirm: true,
218 Default: cliui.ConfirmNo,
219 })
220 if err != nil {
221 return err
222 }
223
224 err = client.DeleteWorkspaceProxyByName(ctx, inv.Args[0])
225 if err != nil {
226 return xerrors.Errorf("delete workspace proxy %q: %w", inv.Args[0], err)
227 }
228
229 _, _ = fmt.Fprintf(inv.Stdout, "Workspace proxy %q deleted successfully\n", inv.Args[0])
230 return nil
231 },
232 }
233
234 return cmd
235}
236
237func (r *RootCmd) createProxy() *serpent.Command {
238 var (

Callers 1

workspaceProxyMethod · 0.95

Calls 7

InitClientMethod · 0.95
SkipPromptOptionFunction · 0.92
PromptFunction · 0.92
WorkspaceProxyByNameMethod · 0.80
ContextMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected