-
Notifications
You must be signed in to change notification settings - Fork 19
/
dbaas_migration_status.go
56 lines (41 loc) · 1.56 KB
/
dbaas_migration_status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package cmd
import (
"fmt"
v2 "github.com/exoscale/egoscale/v2"
exoapi "github.com/exoscale/egoscale/v2/api"
"github.com/spf13/cobra"
)
type dbaasMigrationStatusCmd struct {
cliCommandSettings `cli-cmd:"-"`
_ bool `cli-cmd:"status"`
Name string `cli-arg:"#"`
Zone string `cli-short:"z" cli-usage:"Database Service zone"`
}
func (c *dbaasMigrationStatusCmd) cmdAliases() []string { return []string{} }
func (c *dbaasMigrationStatusCmd) cmdShort() string {
return "Migration status of a Database"
}
func (c *dbaasMigrationStatusCmd) cmdLong() string {
return "This command shows the status of the migration of a Database."
}
func (c *dbaasMigrationStatusCmd) cmdPreRun(cmd *cobra.Command, args []string) error {
cmdSetZoneFlagFromDefault(cmd)
return cliCommandDefaultPreRun(c, cmd, args)
}
type databaseMigrationStatus v2.DatabaseMigrationStatus
func (o *databaseMigrationStatus) toJSON() { outputJSON(o) }
func (o *databaseMigrationStatus) toText() { outputText(o) }
func (o *databaseMigrationStatus) toTable() { outputTable(o) }
func (c *dbaasMigrationStatusCmd) cmdRun(cmd *cobra.Command, args []string) error {
ctx := exoapi.WithEndpoint(gContext, exoapi.NewReqEndpoint(gCurrentAccount.Environment, c.Zone))
res, err := cs.GetDatabaseMigrationStatus(ctx, c.Zone, c.Name)
if err != nil {
return fmt.Errorf("failed to retrieve migration status: %s", err)
}
return c.outputFunc((*databaseMigrationStatus)(res), nil)
}
func init() {
cobra.CheckErr(registerCLICommand(dbaasMigrationCmd, &dbaasMigrationStatusCmd{
cliCommandSettings: defaultCLICmdSettings(),
}))
}