Skip to content

Extend Provider interface with lifecycle methods#44

Merged
renecannao merged 1 commit intomasterfrom
phase2b/task1-extend-provider
Mar 24, 2026
Merged

Extend Provider interface with lifecycle methods#44
renecannao merged 1 commit intomasterfrom
phase2b/task1-extend-provider

Conversation

@renecannao
Copy link
Copy Markdown

@renecannao renecannao commented Mar 24, 2026

Summary

  • Add SandboxConfig and SandboxInfo types to providers/provider.go
  • Extend the Provider interface with FindBinary, CreateSandbox, StartSandbox, and StopSandbox methods
  • Add stub implementations in MySQLProvider that return "not yet migrated" errors
  • Update mock provider in tests to satisfy the extended interface

Test plan

  • go test ./providers/... -v — all 7 tests pass
  • go build -o dbdeployer . — builds successfully

Closes #36

Summary by CodeRabbit

Release Notes

  • Refactor
    • Extended provider interface with methods for sandbox binary discovery, creation, and lifecycle management.
    • Introduced SandboxConfig and SandboxInfo types to standardize sandbox configuration and operational state across providers.

Copilot AI review requested due to automatic review settings March 24, 2026 01:36
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5063de32-aa12-4e17-9415-3ef96b3a4038

📥 Commits

Reviewing files that changed from the base of the PR and between 6d59eb7 and 4dbdfd7.

📒 Files selected for processing (3)
  • providers/mysql/mysql.go
  • providers/provider.go
  • providers/provider_test.go

📝 Walkthrough

Walkthrough

Added four sandbox lifecycle methods (FindBinary, CreateSandbox, StartSandbox, StopSandbox) to the Provider interface along with two new types (SandboxConfig and SandboxInfo). MySQLProvider now includes stub implementations that return errors directing users to invoke sandbox functionality via the sandbox package. Test mock provider updated to satisfy the expanded interface.

Changes

Cohort / File(s) Summary
Provider Interface & Types
providers/provider.go
Added SandboxConfig struct with version, directory, ports, host, and credentials fields; added SandboxInfo struct with directory, port, socket, and status metadata; extended Provider interface with four new lifecycle methods: FindBinary, CreateSandbox, StartSandbox, StopSandbox.
MySQLProvider Implementation
providers/mysql/mysql.go
Added stub implementations of four lifecycle methods to MySQLProvider, each returning an error indicating sandbox functionality should be invoked via the sandbox package.
Test Mock Provider
providers/provider_test.go
Extended mockProvider with stub implementations of four lifecycle methods to satisfy the expanded Provider interface contract.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Sandbox methods hop into place,
Lifecycle steps now set the pace,
Config and info types take flight,
MySQLProvider stubs see the light,
Interface grows, the future's bright! 🌱

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch phase2b/task1-extend-provider

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.

@renecannao renecannao merged commit 800992b into master Mar 24, 2026
13 of 16 checks passed
@renecannao renecannao deleted the phase2b/task1-extend-provider branch March 24, 2026 01:36
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

This PR extends the providers.Provider abstraction to support sandbox lifecycle operations (binary discovery + create/start/stop), laying groundwork for additional providers (e.g., ProxySQL) while keeping the existing MySQL provider behavior unchanged via stub methods.

Changes:

  • Added SandboxConfig / SandboxInfo types and extended the Provider interface with FindBinary, CreateSandbox, StartSandbox, and StopSandbox.
  • Added stub implementations of the new lifecycle methods to MySQLProvider.
  • Updated the provider registry unit test mock to satisfy the expanded interface.

Reviewed changes

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

File Description
providers/provider.go Introduces sandbox config/info structs and expands the Provider interface with lifecycle methods.
providers/mysql/mysql.go Implements the new interface methods on MySQLProvider as stubs (currently returning “not yet migrated” errors).
providers/provider_test.go Extends the mock provider used in registry tests to implement the new interface methods.

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

Comment on lines +39 to +41
func (p *MySQLProvider) CreateSandbox(config providers.SandboxConfig) (*providers.SandboxInfo, error) {
return nil, fmt.Errorf("MySQLProvider.CreateSandbox: use sandbox package directly (not yet migrated)")
}
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 stub returns fmt.Errorf with a constant string and no formatting args; staticcheck (S1028) flags this. Prefer errors.New(...) for constant strings, or a shared sentinel error that you wrap with %w for caller detection.

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +45
func (p *MySQLProvider) StartSandbox(dir string) error {
return fmt.Errorf("MySQLProvider.StartSandbox: use sandbox package directly (not yet migrated)")
}
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.

fmt.Errorf is used here with a constant string and no formatting args; staticcheck (S1028) will flag it in CI. Use errors.New for constant errors (or wrap a sentinel error with %w).

Copilot uses AI. Check for mistakes.
Comment on lines +47 to +49
func (p *MySQLProvider) StopSandbox(dir string) error {
return fmt.Errorf("MySQLProvider.StopSandbox: use sandbox package directly (not yet migrated)")
}
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.

Same as above: fmt.Errorf with a constant string and no formatting args is flagged by staticcheck (S1028). Prefer errors.New(...) (or wrap a shared sentinel error with %w).

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +37
func (p *MySQLProvider) FindBinary(version string) (string, error) {
return "", fmt.Errorf("MySQLProvider.FindBinary: use sandbox package directly (not yet migrated)")
}
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.

These stub methods use fmt.Errorf with a constant string and no formatting args. staticcheck (S1028) recommends using errors.New for constant error strings (or define a sentinel error and wrap it with %w). This will fail the repo's golangci-lint CI job as-is.

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.

Extend Provider interface with lifecycle methods

2 participants