()
| 190 | } |
| 191 | |
| 192 | func (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 | |
| 237 | func (r *RootCmd) createProxy() *serpent.Command { |
| 238 | var ( |
no test coverage detected