Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions providers/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ func (p *MySQLProvider) DefaultPorts() providers.PortRange {
}
}

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

func (p *MySQLProvider) CreateSandbox(config providers.SandboxConfig) (*providers.SandboxInfo, error) {
return nil, fmt.Errorf("MySQLProvider.CreateSandbox: use sandbox package directly (not yet migrated)")
}
Comment on lines +39 to +41
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.

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

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

func Register(reg *providers.Registry) error {
return reg.Register(NewMySQLProvider())
}
31 changes: 28 additions & 3 deletions providers/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,39 @@ import (
"sort"
)

// SandboxConfig holds provider-agnostic sandbox configuration.
type SandboxConfig struct {
Version string
Dir string // sandbox directory path
Port int // primary port
AdminPort int // admin/management port (0 if not applicable)
Host string // bind address
DbUser string // admin username
DbPassword string // admin password
Options map[string]string // provider-specific key-value options
}

// SandboxInfo describes a deployed sandbox instance.
type SandboxInfo struct {
Dir string
Port int
Socket string
Status string // "running", "stopped"
}

// Provider is the core abstraction for deploying database infrastructure.
// Phase 2a defines a minimal interface (Name, ValidateVersion, DefaultPorts).
// Phase 2b will add CreateSandbox, Start, Stop, Destroy, HealthCheck when
// ProxySQL and other providers need them.
type Provider interface {
Name() string
ValidateVersion(version string) error
DefaultPorts() PortRange
// FindBinary returns the path to the provider's main binary, or error if not found.
FindBinary(version string) (string, error)
// CreateSandbox deploys a new sandbox instance.
CreateSandbox(config SandboxConfig) (*SandboxInfo, error)
// StartSandbox starts a stopped sandbox.
StartSandbox(dir string) error
// StopSandbox stops a running sandbox.
StopSandbox(dir string) error
}

type PortRange struct {
Expand Down
4 changes: 4 additions & 0 deletions providers/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ type mockProvider struct{ name string }
func (m *mockProvider) Name() string { return m.name }
func (m *mockProvider) ValidateVersion(version string) error { return nil }
func (m *mockProvider) DefaultPorts() PortRange { return PortRange{BasePort: 9999, PortsPerInstance: 1} }
func (m *mockProvider) FindBinary(version string) (string, error) { return "/usr/bin/mock", nil }
func (m *mockProvider) CreateSandbox(config SandboxConfig) (*SandboxInfo, error) { return &SandboxInfo{Dir: "/tmp/mock"}, nil }
func (m *mockProvider) StartSandbox(dir string) error { return nil }
func (m *mockProvider) StopSandbox(dir string) error { return nil }

func TestRegistryRegisterAndGet(t *testing.T) {
reg := NewRegistry()
Expand Down
Loading