-
Notifications
You must be signed in to change notification settings - Fork 2
Add 'dbdeployer providers' CLI command #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -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) | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error returned from You will also need to import the p, err := providers.DefaultRegistry.Get(name)
if err != nil {
fmt.Fprintf(os.Stderr, "error getting provider %q: %v\n", name, err)
continue
}
|
||||||||||||||
| 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 | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
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) | |
| } | |
| // 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) | |
| } | |
| } |
There was a problem hiding this comment.
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/*.gofiles (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.