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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## To Be Released

* feat(cmd) add database-list-plans

## 1.43.2

* fix(databases next generation): fix plan names in examples
Expand Down
1 change: 1 addition & 0 deletions cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ var (
// Databases next generation
&databasesListCommand,
&databaseInfoCommand,
&databaseListPlansCommand,
&databaseCreateCommand,
&databaseUpgradeCommand,
&databaseDestroyCommand,
Expand Down
30 changes: 30 additions & 0 deletions cmd/databases_ng.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,36 @@ var (
},
}

databaseListPlansCommand = cli.Command{
Name: "database-list-plans",
Category: "Databases DR",
Usage: "List the available plans for database Dedicated Resources",
Description: CommandDescription{
Description: "List all the available plans for database Dedicated Resources",
Examples: []string{
"scalingo database-list-plans postgresql-ng",
},
SeeAlso: []string{"databases", "database-info", "database-create", "database-upgrade", "database-destroy"},
}.Render(),
Action: func(ctx context.Context, c *cli.Command) error {
technology := c.Args().First()
Copy link
Contributor

Choose a reason for hiding this comment

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

question: do we want a failsafe on the technology? Because here nothing prevents to ask for SR plans, correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes and I think it's still good at least for now. It'll be changed by DBFCC

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright.

if technology == "" {
io.Error("Please provide a database technology")
return cli.ShowCommandHelp(ctx, c, "database-list-plans")
}

err := dbng.ListPlans(ctx, technology)
if err != nil {
errorQuit(ctx, err)
}

return nil
},
ShellComplete: func(_ context.Context, c *cli.Command) {
_ = autocomplete.CmdFlagsAutoComplete(c, "database-list-plans")
},
}

databaseCreateCommand = cli.Command{
Name: "database-create",
Category: "Databases DR",
Expand Down
16 changes: 16 additions & 0 deletions dbng/list_plans.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dbng

import (
"context"

"github.com/Scalingo/cli/addonproviders"
"github.com/Scalingo/go-utils/errors/v2"
)

func ListPlans(ctx context.Context, technology string) error {
err := addonproviders.Plans(ctx, technology)
if err != nil {
return errors.Wrap(ctx, err, "list the plans of the database")
}
return nil
}