Skip to content

Add 'dbdeployer providers' CLI command#34

Merged
renecannao merged 2 commits intomasterfrom
phase2a/task6-providers-cmd
Mar 24, 2026
Merged

Add 'dbdeployer providers' CLI command#34
renecannao merged 2 commits intomasterfrom
phase2a/task6-providers-cmd

Conversation

@renecannao
Copy link
Copy Markdown

Summary

  • Adds a new dbdeployer providers command that lists all registered deployment providers with their port configuration
  • Uses the DefaultRegistry from the providers package to enumerate and display provider details

Test plan

  • go build succeeds
  • ./dbdeployer providers outputs: mysql (base port: 3306, ports per instance: 3)
  • ./dbdeployer --help lists the providers command

Closes #30

Copilot AI review requested due to automatic review settings March 24, 2026 01:04
@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 16 minutes and 20 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: 2eebfee8-3418-4639-b09c-059a1a5acedc

📥 Commits

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

📒 Files selected for processing (2)
  • cmd/providers.go
  • cmd/single.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch phase2a/task6-providers-cmd

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 introduces a new command to the dbdeployer tool, allowing users to easily inspect available deployment providers and their associated port configurations. Additionally, it enhances the robustness of single sandbox deployments by incorporating a validation step that checks the requested database version against the capabilities defined by the selected provider.

Highlights

  • New CLI Command: Added a new dbdeployer providers command to list registered deployment providers.
  • Provider Information Display: The new command displays each provider's name, base port, and ports per instance.
  • Version Validation Integration: Integrated provider-based version validation into the single sandbox deployment process.
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.

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 introduces a new dbdeployer providers command to list available deployment providers, which is a useful addition for discoverability. The implementation is clean. I've found one potential issue in the new cmd/providers.go file regarding error handling that could lead to a panic. My specific comment provides a suggestion to fix it. The changes in cmd/single.go for version validation are a good step towards more robust deployments.

Comment thread cmd/providers.go
Long: "Lists all registered providers that can be used for sandbox deployment",
Run: func(cmd *cobra.Command, args []string) {
for _, name := range providers.DefaultRegistry.List() {
p, _ := providers.DefaultRegistry.Get(name)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The error returned from providers.DefaultRegistry.Get(name) is ignored. While it's unlikely to fail in the current logic (as you're iterating over a list from the same registry), not handling the error could lead to a panic on the next line if p is nil. It's safer to handle the error.

You will also need to import the os package to use os.Stderr.

p, err := providers.DefaultRegistry.Get(name)
if err != nil {
	fmt.Fprintf(os.Stderr, "error getting provider %q: %v\n", name, err)
	continue
}

@renecannao renecannao merged commit af08f7d into master Mar 24, 2026
16 of 18 checks passed
@renecannao renecannao deleted the phase2a/task6-providers-cmd branch March 24, 2026 01:06
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 CLI support for enumerating registered deployment providers and begins integrating the provider abstraction into the single-sandbox deployment flow.

Changes:

  • Introduces dbdeployer providers command to list registered providers and their default port ranges.
  • Adds provider-based version validation step to deploy single.
  • Wires the command into the Cobra root command.

Reviewed changes

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

File Description
cmd/single.go Adds provider lookup and ValidateVersion call before creating a single sandbox.
cmd/providers.go New providers root command that lists entries from providers.DefaultRegistry.

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

Comment thread cmd/single.go
Comment on lines +450 to +457
// 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 is hardcoded to "mysql" even though fillSandboxDefinition detects/sets sd.Flavor. This will validate versions against the wrong provider for non-MySQL flavors (e.g. MariaDB/Percona) and will likely break once providers implement flavor-specific ValidateVersion logic. Please select the provider based on sd.Flavor (or skip provider validation when no matching provider is registered) instead of hardcoding "mysql".

Suggested change
// 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)
}
// Determine provider from sd.Flavor, defaulting to "mysql" for backward compatibility
providerName := sd.Flavor
if providerName == "" {
providerName = "mysql"
}
p, provErr := providers.DefaultRegistry.Get(providerName)
if provErr != nil {
// For non-MySQL flavors, skip provider validation if no matching provider is registered
if providerName == "mysql" {
common.Exitf(1, "provider error: %s", provErr)
}
} else {
if err := p.ValidateVersion(sd.Version); err != nil {
common.Exitf(1, "version validation failed: %s", err)
}
}

Copilot uses AI. Check for mistakes.
Comment thread cmd/providers.go
Comment on lines +1 to +3
package cmd

import (
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.

This new command file is missing the standard DBDeployer Apache 2.0 license header comment that appears at the top of the other cmd/*.go files (e.g. cmd/root.go:1-15, cmd/versions.go:1-15). Please add the same header here for consistency and to avoid licensing ambiguity.

Copilot uses AI. Check for mistakes.
Comment thread cmd/providers.go
Long: "Lists all registered providers that can be used for sandbox deployment",
Run: func(cmd *cobra.Command, args []string) {
for _, name := range providers.DefaultRegistry.List() {
p, _ := providers.DefaultRegistry.Get(name)
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.

providers.DefaultRegistry.Get(name) errors are currently ignored, which would lead to a nil dereference on p.DefaultPorts() if the registry ever becomes inconsistent. Even if this is unlikely given name comes from List(), it’s safer to handle the error (e.g., exit or print a clear message and continue).

Suggested change
p, _ := providers.DefaultRegistry.Get(name)
p, err := providers.DefaultRegistry.Get(name)
if err != nil {
fmt.Fprintf(cmd.ErrOrStderr(), "failed to get provider %q: %v\n", name, err)
continue
}

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 'dbdeployer providers' CLI command

2 participants