Skip to content

Commit

Permalink
backup: implement restore-id handling (#328)
Browse files Browse the repository at this point in the history
Signed-off-by: Nandor Kracser <[email protected]>
  • Loading branch information
bonifaido authored Nov 11, 2020
1 parent 07de764 commit b645ea9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion internal/cli/command/cluster/restore/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func runCreate(banzaiCli cli.Cli, options createOptions) error {
return errors.WrapIfWithDetails(err, "failed to create restore", "clusterID", clusterID, "backupName", options.backupName)
}

log.Infof("Starting to restore cluster. You can check the status with `banzai cluster restore result --restoreId=%d`", response.Restore.Id)
log.Infof("Starting to restore cluster. You can check the status with `banzai cluster restore result --restore-id=%d`", response.Restore.Id)

return nil
}
Expand Down
19 changes: 7 additions & 12 deletions internal/cli/command/cluster/restore/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package restore
import (
"context"
"fmt"
"strconv"

"emperror.dev/errors"
log "github.com/sirupsen/logrus"
Expand All @@ -30,6 +29,8 @@ import (

type resultOptions struct {
clustercontext.Context

restoreID int32
}

func newResultCommand(banzaiCli cli.Cli) *cobra.Command {
Expand All @@ -49,28 +50,22 @@ func newResultCommand(banzaiCli cli.Cli) *cobra.Command {
return errors.WrapIf(err, "failed to initialize options")
}

return showResult(banzaiCli, options, args)
return showResult(banzaiCli, options)
},
}
flags := cmd.Flags()
flags.Int32VarP(&options.restoreID, "restore-id", "", 0, "Restore ID")
options.Context = clustercontext.NewClusterContext(cmd, banzaiCli, "result")

return cmd
}

func showResult(banzaiCli cli.Cli, options resultOptions, args []string) error {
func showResult(banzaiCli cli.Cli, options resultOptions) error {
client := banzaiCli.Client()
orgID := banzaiCli.Context().OrganizationID()
clusterID := options.ClusterID()

var restoreID int32
if len(args) > 0 {
if id, err := strconv.ParseUint(args[0], 10, 64); err != nil {
return errors.WrapIf(err, "failed to parse restoreID")
} else {
restoreID = int32(id)
}
}

restoreID := options.restoreID
if restoreID == 0 {
if banzaiCli.Interactive() {
restore, err := askRestore(client, orgID, clusterID)
Expand Down

0 comments on commit b645ea9

Please sign in to comment.