Skip to content

Conversation

littlecxm
Copy link

@littlecxm littlecxm commented Aug 20, 2025

PBM-1600 Powered by Pull Request Badge

Hi!

I'm submitting PR to add implement in PBM-1600.
I have tested this prompt on my env (debian-amd64).

Thanks a lot for this awesome project and maintainer!

@it-percona-cla
Copy link

it-percona-cla commented Aug 20, 2025

CLA assistant check
All committers have signed the CLA.

@radoslawszulgo radoslawszulgo requested a review from Copilot August 21, 2025 12:42
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements an interactive confirmation prompt for restore operations, aligning with the JIRA ticket PBM-1600. The change adds a safety mechanism requiring user confirmation before executing potentially destructive restore operations.

Key changes:

  • Extracted confirmation prompt functionality from delete command to a reusable utility
  • Added interactive confirmation prompt to restore operations with bypass option
  • Improved console output formatting for restore operations

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
pbm/util/cmd_prompt.go New utility function for interactive confirmation prompts with TTY detection and colored output
pbm/errors/errors.go Added standard user cancellation error for consistent error handling
cmd/pbm/restore.go Integrated confirmation prompt into restore workflow with bypass flag and improved output formatting
cmd/pbm/delete.go Refactored to use shared confirmation utility and standardized error handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -49,6 +49,7 @@ type restoreOpts struct {
nsFrom string
nsTo string
usersAndRoles bool
confirmYes bool
Copy link
Preview

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The confirmYes field is added to the struct but there's no visible command-line flag definition or initialization code in this diff. Ensure that a corresponding CLI flag (like --yes or --confirm) is properly defined and wired to this field.

Copilot uses AI. Check for mistakes.

}

if runtime.GOOS == "linux" {
question = fmt.Sprintf("\033[1;33m%s\033[0m", question) // Yellow text for Linux terminals
Copy link
Preview

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The color formatting is only applied to Linux systems, but many other Unix-like systems (macOS, FreeBSD, etc.) also support ANSI color codes. Consider using a more inclusive condition like runtime.GOOS != "windows" or detecting terminal color support more robustly.

Suggested change
question = fmt.Sprintf("\033[1;33m%s\033[0m", question) // Yellow text for Linux terminals
if runtime.GOOS != "windows" {
question = fmt.Sprintf("\033[1;33m%s\033[0m", question) // Yellow text for Unix-like terminals

Copilot uses AI. Check for mistakes.

"context"
"fmt"
"github.com/percona/percona-backup-mongodb/pbm/util"
Copy link
Preview

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import should follow Go conventions by being grouped with other third-party imports and maintaining alphabetical order. Move this import to be grouped with other project imports.

Suggested change
"github.com/percona/percona-backup-mongodb/pbm/util"

Copilot uses AI. Check for mistakes.

return nil, errors.Wrap(err, "send command")
}

fmt.Printf("Starting restore")
Copy link
Preview

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message "Starting restore" lacks context compared to the original message that included the backup name and other details. Consider including key restore information in this status message for better user experience.

Suggested change
fmt.Printf("Starting restore")
fmt.Printf("Starting restore: %s%s%s\n", name, pitrs, bcpName)

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants