-
Notifications
You must be signed in to change notification settings - Fork 3
feat(app): add vcr app remove command [APIAPEX-2823] #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4d05a54
docs: add vcr app delete design spec [APIAPEX-2823]
gorkarevilla 2d04ed6
docs: add vcr app delete implementation plan [APIAPEX-2823]
gorkarevilla 1f3baf1
feat(api): add DeleteVonageApplication to DeploymentClient [APIAPEX-2…
gorkarevilla 8cb9c22
feat(cmdutil): add DeleteVonageApplication to DeploymentInterface [AP…
gorkarevilla d7f5459
feat(app): implement vcr app delete command [APIAPEX-2823]
gorkarevilla 081f338
test(app): add tests for vcr app delete command [APIAPEX-2823]
gorkarevilla e39baa4
feat(app): register vcr app delete subcommand [APIAPEX-2823]
gorkarevilla 21b0957
feat(api): add DeleteVonageApplication to DeploymentClient [APIAPEX-2…
gorkarevilla aa6e115
refactor(app): rename delete to remove for consistency with instance …
gorkarevilla b38fcc4
docs: update spec and plan to reflect remove rename [APIAPEX-2823]
gorkarevilla 23c5877
fix: doc tab
gorkarevilla 63ff24b
chore: ignore docs/superpowers agent working files [APIAPEX-2823]
gorkarevilla 516f208
fix(app/remove): address Copilot review comments [APIAPEX-2823]
gorkarevilla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,3 +17,6 @@ lefthook-local.yml | |
|
|
||
| # Node modules (for commitlint) | ||
| node_modules/ | ||
|
|
||
| # Agent working files | ||
| docs/superpowers/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package remove | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
|
|
||
| "github.com/MakeNowJust/heredoc" | ||
| "github.com/spf13/cobra" | ||
|
|
||
| "vonage-cloud-runtime-cli/pkg/api" | ||
| "vonage-cloud-runtime-cli/pkg/cmdutil" | ||
| ) | ||
|
|
||
| type Options struct { | ||
| cmdutil.Factory | ||
|
|
||
| ApplicationID string | ||
| SkipPrompts bool | ||
| } | ||
|
|
||
| func NewCmdAppRemove(f cmdutil.Factory) *cobra.Command { | ||
| opts := Options{ | ||
| Factory: f, | ||
| } | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "remove <applicationID>", | ||
| Aliases: []string{"rm"}, | ||
| Short: "Remove a Vonage application", | ||
| Long: heredoc.Doc(`Remove a Vonage application from your account. | ||
|
|
||
| This command permanently removes a Vonage application and its associated | ||
| credentials. Any VCR instances linked to this application will lose their | ||
| authentication credentials on next restart. | ||
|
|
||
| WARNING: This action is irreversible. Make sure no running instances | ||
| depend on this application before removing it. | ||
| `), | ||
| Example: heredoc.Doc(` | ||
| # Remove an application (will prompt for confirmation) | ||
| $ vcr app remove 12345678-1234-1234-1234-123456789abc | ||
|
|
||
| # Remove without confirmation prompt (useful for CI/CD) | ||
| $ vcr app remove 12345678-1234-1234-1234-123456789abc --yes | ||
|
|
||
| # Using the short alias | ||
| $ vcr app rm 12345678-1234-1234-1234-123456789abc --yes | ||
| `), | ||
| Args: cobra.ExactArgs(1), | ||
| RunE: func(_ *cobra.Command, args []string) error { | ||
| opts.ApplicationID = args[0] | ||
|
|
||
| ctx, cancel := context.WithDeadline(context.Background(), opts.Deadline()) | ||
| defer cancel() | ||
|
|
||
| return runRemove(ctx, &opts) | ||
| }, | ||
| } | ||
|
|
||
| cmd.Flags().BoolVarP(&opts.SkipPrompts, "yes", "y", false, "Skip confirmation prompt (use with caution)") | ||
|
|
||
| return cmd | ||
| } | ||
|
|
||
| func runRemove(ctx context.Context, opts *Options) error { | ||
| io := opts.IOStreams() | ||
| c := io.ColorScheme() | ||
|
|
||
| if io.CanPrompt() && !opts.SkipPrompts { | ||
| if !opts.Survey().AskYesNo(fmt.Sprintf("Are you sure you want to remove application %q?", opts.ApplicationID)) { | ||
| fmt.Fprintf(io.ErrOut, "%s Application removal aborted\n", c.WarningIcon()) | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
| spinner := cmdutil.DisplaySpinnerMessageWithHandle(fmt.Sprintf(" Removing application %q...", opts.ApplicationID)) | ||
| err := opts.DeploymentClient().DeleteVonageApplication(ctx, opts.ApplicationID) | ||
| spinner.Stop() | ||
| if err != nil { | ||
| if errors.Is(err, api.ErrNotFound) { | ||
| return fmt.Errorf("application %q could not be found or may have already been deleted", opts.ApplicationID) | ||
| } | ||
| return fmt.Errorf("failed to remove application: %w", err) | ||
| } | ||
|
|
||
| fmt.Fprintf(io.Out, "%s Application %q successfully removed\n", c.SuccessIcon(), opts.ApplicationID) | ||
|
|
||
| return nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.