File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ func BuildCommands(rootCmd *cobra.Command, conf *config.Config) {
103103 databaseCommand := commands .BuildCommand (database .BaseDatabaseCommand (), rootCmd , conf )
104104 commands .BuildCommand (database .ListCommand (), databaseCommand .Cobra (), conf )
105105 commands .BuildCommand (database .ShowCommand (), databaseCommand .Cobra (), conf )
106+ commands .BuildCommand (database .TypesCommand (), databaseCommand .Cobra (), conf )
106107
107108 // Misc
108109 commands .BuildCommand (
Original file line number Diff line number Diff line change 1+ package database
2+
3+ import (
4+ "github.com/UpCloudLtd/upcloud-cli/internal/commands"
5+ "github.com/UpCloudLtd/upcloud-cli/internal/output"
6+ "github.com/UpCloudLtd/upcloud-go-api/v4/upcloud/request"
7+ )
8+
9+ // TypesCommand creates the "database types" command
10+ func TypesCommand () commands.Command {
11+ return & typesCommand {
12+ BaseCommand : commands .New ("types" , "List available database types" , "upctl database types" ),
13+ }
14+ }
15+
16+ type typesCommand struct {
17+ * commands.BaseCommand
18+ }
19+
20+ // ExecuteWithoutArguments implements commands.NoArgumentCommand
21+ func (s * typesCommand ) ExecuteWithoutArguments (exec commands.Executor ) (output.Output , error ) {
22+ svc := exec .All ()
23+ dbTypes , err := svc .GetManagedDatabaseServiceTypes (& request.GetManagedDatabaseServiceTypesRequest {})
24+ if err != nil {
25+ return nil , err
26+ }
27+
28+ rows := []output.TableRow {}
29+ for _ , dbType := range dbTypes {
30+ rows = append (rows , output.TableRow {
31+ dbType .Name ,
32+ dbType .Description ,
33+ dbType .LatestAvailableVersion ,
34+ })
35+ }
36+
37+ return output.Table {
38+ Columns : []output.TableColumn {
39+ {Key : "name" , Header : "Name" },
40+ {Key : "description" , Header : "Description" },
41+ {Key : "latest_available_version" , Header : "Latest Available Version" },
42+ },
43+ Rows : rows ,
44+ }, nil
45+ }
You can’t perform that action at this time.
0 commit comments