Skip to content

Commit b645ea9

Browse files
authored
backup: implement restore-id handling (#328)
Signed-off-by: Nandor Kracser <[email protected]>
1 parent 07de764 commit b645ea9

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

internal/cli/command/cluster/restore/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func runCreate(banzaiCli cli.Cli, options createOptions) error {
8383
return errors.WrapIfWithDetails(err, "failed to create restore", "clusterID", clusterID, "backupName", options.backupName)
8484
}
8585

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

8888
return nil
8989
}

internal/cli/command/cluster/restore/result.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package restore
1717
import (
1818
"context"
1919
"fmt"
20-
"strconv"
2120

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

3130
type resultOptions struct {
3231
clustercontext.Context
32+
33+
restoreID int32
3334
}
3435

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

52-
return showResult(banzaiCli, options, args)
53+
return showResult(banzaiCli, options)
5354
},
5455
}
56+
flags := cmd.Flags()
57+
flags.Int32VarP(&options.restoreID, "restore-id", "", 0, "Restore ID")
5558
options.Context = clustercontext.NewClusterContext(cmd, banzaiCli, "result")
5659

5760
return cmd
5861
}
5962

60-
func showResult(banzaiCli cli.Cli, options resultOptions, args []string) error {
63+
func showResult(banzaiCli cli.Cli, options resultOptions) error {
6164
client := banzaiCli.Client()
6265
orgID := banzaiCli.Context().OrganizationID()
6366
clusterID := options.ClusterID()
6467

65-
var restoreID int32
66-
if len(args) > 0 {
67-
if id, err := strconv.ParseUint(args[0], 10, 64); err != nil {
68-
return errors.WrapIf(err, "failed to parse restoreID")
69-
} else {
70-
restoreID = int32(id)
71-
}
72-
}
73-
68+
restoreID := options.restoreID
7469
if restoreID == 0 {
7570
if banzaiCli.Interactive() {
7671
restore, err := askRestore(client, orgID, clusterID)

0 commit comments

Comments
 (0)