Skip to content

Add provider validation to deployment commands#35

Merged
renecannao merged 2 commits intomasterfrom
phase2a/task4-5-cmd-validation
Mar 24, 2026
Merged

Add provider validation to deployment commands#35
renecannao merged 2 commits intomasterfrom
phase2a/task4-5-cmd-validation

Conversation

@renecannao
Copy link
Copy Markdown

Closes #28
Closes #29

Summary

  • Add provider version validation to cmd/single.go after fillSandboxDefinition() and before CreateStandaloneSandbox()
  • Add the same provider validation pattern to cmd/replication.go (before CreateReplicationSandbox) and cmd/multiple.go (before CreateMultipleSandbox)
  • Each deployment path now validates sd.Version against the MySQL provider via providers.DefaultRegistry

Test plan

  • go build succeeds
  • dbdeployer deploy single 8.4.4 deploys successfully
  • dbdeployer delete all --skip-confirm cleans up

Copilot AI review requested due to automatic review settings March 24, 2026 01:06
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

Warning

Rate limit exceeded

@renecannao has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 28 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5ef40f6-9771-4368-a3ab-8ac723eed235

📥 Commits

Reviewing files that changed from the base of the PR and between 42f7e7f and c84d199.

📒 Files selected for processing (3)
  • cmd/multiple.go
  • cmd/replication.go
  • cmd/single.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch phase2a/task4-5-cmd-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the dbdeployer tool's robustness by integrating provider-based version validation into its sandbox deployment commands. It ensures that the specified MySQL version is compatible with the mysql provider before proceeding with the creation of single, replication, or multiple sandboxes, preventing potential deployment failures due to unsupported versions.

Highlights

  • Single Sandbox Validation: Implemented provider version validation in cmd/single.go after fillSandboxDefinition() and before CreateStandaloneSandbox().
  • Replication Sandbox Validation: Applied the same provider validation pattern to cmd/replication.go before CreateReplicationSandbox().
  • Multiple Sandbox Validation: Extended the provider validation to cmd/multiple.go before CreateMultipleSandbox().
  • Centralized Version Validation: Ensured all deployment paths now validate sd.Version against the MySQL provider using providers.DefaultRegistry.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@renecannao renecannao merged commit c6737de into master Mar 24, 2026
16 checks passed
@renecannao renecannao deleted the phase2a/task4-5-cmd-validation branch March 24, 2026 01:06
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds provider version validation to the deploy commands for single, multiple, and replication sandboxes. The implementation correctly integrates with the new provider registry. However, the validation logic has been duplicated across three different files. My review includes suggestions to refactor this duplicated code into a shared helper function to improve code maintainability and adhere to the DRY (Don't Repeat Yourself) principle.

Comment thread cmd/multiple.go
Comment on lines +32 to +40
// Validate version with provider
// TODO: Phase 2b — determine provider from sd.Flavor instead of hardcoding "mysql"
p, provErr := providers.DefaultRegistry.Get("mysql")
if provErr != nil {
common.Exitf(1, "provider error: %s", provErr)
}
if provErr = p.ValidateVersion(sd.Version); provErr != nil {
common.Exitf(1, "version validation failed: %s", provErr)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This provider validation logic is duplicated in cmd/replication.go and cmd/single.go. To improve maintainability and follow the DRY (Don't Repeat Yourself) principle, this logic should be extracted into a common helper function. For example, you could create a validateProvider(sd sandbox.SandboxDef) function in cmd/single.go (alongside fillSandboxDefinition) and call it from all three command files.

Comment thread cmd/replication.go
Comment on lines +32 to +40
// Validate version with provider
// TODO: Phase 2b — determine provider from sd.Flavor instead of hardcoding "mysql"
p, provErr := providers.DefaultRegistry.Get("mysql")
if provErr != nil {
common.Exitf(1, "provider error: %s", provErr)
}
if provErr = p.ValidateVersion(sd.Version); provErr != nil {
common.Exitf(1, "version validation failed: %s", provErr)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This provider validation logic is duplicated in cmd/multiple.go and cmd/single.go. To improve maintainability and follow the DRY (Don't Repeat Yourself) principle, this logic should be extracted into a common helper function. For example, you could create a validateProvider(sd sandbox.SandboxDef) function in cmd/single.go (alongside fillSandboxDefinition) and call it from all three command files.

Comment thread cmd/single.go
Comment on lines +449 to +457
// Validate version with provider
// TODO: Phase 2b — determine provider from sd.Flavor instead of hardcoding "mysql"
p, provErr := providers.DefaultRegistry.Get("mysql")
if provErr != nil {
common.Exitf(1, "provider error: %s", provErr)
}
if provErr = p.ValidateVersion(sd.Version); provErr != nil {
common.Exitf(1, "version validation failed: %s", provErr)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This provider validation logic is duplicated in cmd/multiple.go and cmd/replication.go. To improve maintainability and follow the DRY (Don't Repeat Yourself) principle, this logic should be extracted into a common helper function. For example, you could create a validateProvider(sd sandbox.SandboxDef) function in this file (alongside fillSandboxDefinition) and call it from all three command files.

Copy link
Copy Markdown

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

Adds a provider-backed version validation step to the CLI deployment flows so that sd.Version is checked via providers.DefaultRegistry before sandbox creation, aligning command behavior with the emerging provider abstraction.

Changes:

  • Add MySQL provider lookup + ValidateVersion(sd.Version) to deploy single before CreateStandaloneSandbox.
  • Add the same provider validation step to deploy replication before CreateReplicationSandbox.
  • Add the same provider validation step to deploy multiple before CreateMultipleSandbox.

Reviewed changes

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

File Description
cmd/single.go Performs provider version validation after fillSandboxDefinition() and before standalone sandbox creation.
cmd/replication.go Performs provider version validation before replication sandbox creation.
cmd/multiple.go Performs provider version validation before multiple sandbox creation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/multiple.go
Comment on lines +32 to +40
// Validate version with provider
// TODO: Phase 2b — determine provider from sd.Flavor instead of hardcoding "mysql"
p, provErr := providers.DefaultRegistry.Get("mysql")
if provErr != nil {
common.Exitf(1, "provider error: %s", provErr)
}
if provErr = p.ValidateVersion(sd.Version); provErr != nil {
common.Exitf(1, "version validation failed: %s", provErr)
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The provider lookup + version validation logic is duplicated across multiple deployment commands (single/replication/multiple). Consider extracting this into a shared helper (e.g., validateProviderVersion(sd) in cmd) to reduce drift and make Phase 2b (provider-from-flavor) a smaller change.

Copilot uses AI. Check for mistakes.
Comment thread cmd/multiple.go
common.Exitf(1, "provider error: %s", provErr)
}
if provErr = p.ValidateVersion(sd.Version); provErr != nil {
common.Exitf(1, "version validation failed: %s", provErr)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The failure message version validation failed doesn’t include which provider and version were being validated. Including both (e.g., provider name and sd.Version) would make CLI failures actionable, especially once multiple providers are supported.

Suggested change
common.Exitf(1, "version validation failed: %s", provErr)
common.Exitf(1, "version validation failed for provider %s, version %s: %s", "mysql", sd.Version, provErr)

Copilot uses AI. Check for mistakes.
Comment thread cmd/single.go
Comment on lines +449 to +457
// Validate version with provider
// TODO: Phase 2b — determine provider from sd.Flavor instead of hardcoding "mysql"
p, provErr := providers.DefaultRegistry.Get("mysql")
if provErr != nil {
common.Exitf(1, "provider error: %s", provErr)
}
if provErr = p.ValidateVersion(sd.Version); provErr != nil {
common.Exitf(1, "version validation failed: %s", provErr)
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The provider lookup + version validation logic is duplicated across multiple deployment commands (single/replication/multiple). Consider extracting this into a shared helper (e.g., validateProviderVersion(sd) in cmd) to reduce drift and make Phase 2b (provider-from-flavor) a smaller change.

Copilot uses AI. Check for mistakes.
Comment thread cmd/single.go
Comment on lines +451 to +456
p, provErr := providers.DefaultRegistry.Get("mysql")
if provErr != nil {
common.Exitf(1, "provider error: %s", provErr)
}
if provErr = p.ValidateVersion(sd.Version); provErr != nil {
common.Exitf(1, "version validation failed: %s", provErr)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The failure message version validation failed doesn’t include which provider and version were being validated. Including both (e.g., provider name and sd.Version) would make CLI failures actionable, especially once multiple providers are supported.

Suggested change
p, provErr := providers.DefaultRegistry.Get("mysql")
if provErr != nil {
common.Exitf(1, "provider error: %s", provErr)
}
if provErr = p.ValidateVersion(sd.Version); provErr != nil {
common.Exitf(1, "version validation failed: %s", provErr)
providerName := "mysql"
p, provErr := providers.DefaultRegistry.Get(providerName)
if provErr != nil {
common.Exitf(1, "provider error: %s", provErr)
}
if provErr = p.ValidateVersion(sd.Version); provErr != nil {
common.Exitf(1, "version validation failed for provider %q and version %q: %s", providerName, sd.Version, provErr)

Copilot uses AI. Check for mistakes.
Comment thread cmd/replication.go
Comment on lines +32 to +40
// Validate version with provider
// TODO: Phase 2b — determine provider from sd.Flavor instead of hardcoding "mysql"
p, provErr := providers.DefaultRegistry.Get("mysql")
if provErr != nil {
common.Exitf(1, "provider error: %s", provErr)
}
if provErr = p.ValidateVersion(sd.Version); provErr != nil {
common.Exitf(1, "version validation failed: %s", provErr)
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The provider lookup + version validation logic is duplicated across multiple deployment commands (single/replication/multiple). Consider extracting this into a shared helper (e.g., validateProviderVersion(sd) in cmd) to reduce drift and make Phase 2b (provider-from-flavor) a smaller change.

Copilot uses AI. Check for mistakes.
Comment thread cmd/replication.go
common.Exitf(1, "provider error: %s", provErr)
}
if provErr = p.ValidateVersion(sd.Version); provErr != nil {
common.Exitf(1, "version validation failed: %s", provErr)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The failure message version validation failed doesn’t include which provider and version were being validated. Including both (e.g., provider name and sd.Version) would make CLI failures actionable, especially once multiple providers are supported.

Suggested change
common.Exitf(1, "version validation failed: %s", provErr)
common.Exitf(1, "version validation failed for provider %s, version %s: %s", "mysql", sd.Version, provErr)

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.

Add provider validation to replication and multiple deployments Add provider validation to single sandbox deployment

2 participants