diff --git a/cmd/providers.go b/cmd/providers.go new file mode 100644 index 0000000..bb77329 --- /dev/null +++ b/cmd/providers.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "fmt" + + "github.com/ProxySQL/dbdeployer/providers" + "github.com/spf13/cobra" +) + +var providersCmd = &cobra.Command{ + Use: "providers", + Short: "Shows available deployment providers", + 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) + ports := p.DefaultPorts() + fmt.Printf("%-15s (base port: %d, ports per instance: %d)\n", + name, ports.BasePort, ports.PortsPerInstance) + } + }, +} + +func init() { + rootCmd.AddCommand(providersCmd) +} diff --git a/cmd/single.go b/cmd/single.go index 7df4cc2..4649216 100644 --- a/cmd/single.go +++ b/cmd/single.go @@ -25,6 +25,7 @@ import ( "github.com/ProxySQL/dbdeployer/common" "github.com/ProxySQL/dbdeployer/defaults" "github.com/ProxySQL/dbdeployer/globals" + "github.com/ProxySQL/dbdeployer/providers" "github.com/ProxySQL/dbdeployer/sandbox" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -445,6 +446,15 @@ func singleSandbox(cmd *cobra.Command, args []string) { if err != nil { common.Exitf(1, "error while filling the sandbox definition: %+v", err) } + // 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) + } // When deploying a single sandbox, we disable concurrency sd.RunConcurrently = false err = sandbox.CreateStandaloneSandbox(sd)