Skip to content

Commit

Permalink
[fix] fix code review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
saicaca committed Oct 8, 2023
1 parent 449d662 commit b3cde96
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ type SnapshotInfoData struct {
}

const (
SNAPSHOT_SUBURI = "/SnapshotCloneService"
ACTION_GET_FILE_SNAPSHOT_LIST = "GetFileSnapshotList"
ENTRIES_PER_TIME = 100
SNAPSHOT_QUERY_LIMIT = 100
SNAPSHOT_QUERY_INITIAL_OFFSET = 0
SNAPSHOT_QUERY_CODE_SUCCESS = "0"
LENGTH_EMPTY = 0
)

const (
Expand Down Expand Up @@ -114,7 +115,7 @@ func NewVolumeSnapshotCommand() *SnapshotCommand {
vsCmd := &SnapshotCommand{
FinalCurveCmd: basecmd.FinalCurveCmd{
Use: "snapshot",
Short: "create snapshot of curvebs volume",
Short: "show the snapshot status",
},
}
basecmd.NewFinalCurveCli(&vsCmd.FinalCurveCmd, vsCmd)
Expand Down Expand Up @@ -142,13 +143,10 @@ func (sCmd *SnapshotCommand) RunCommand(cmd *cobra.Command, args []string) error
cobrautil.QueryAction: cobrautil.ActionGetFileSnapshotList,
cobrautil.QueryUser: sCmd.user,
cobrautil.QueryFile: sCmd.filename,
cobrautil.QueryLimit: 100,
cobrautil.QueryOffset: 0,
cobrautil.QueryLimit: SNAPSHOT_QUERY_LIMIT,
cobrautil.QueryOffset: SNAPSHOT_QUERY_INITIAL_OFFSET,
}
count := make(map[int]int)
for _, s := range statusList {
count[s] = 0
}
for {
subUri := cobrautil.NewSnapshotQuerySubUri(params)

Expand All @@ -162,10 +160,10 @@ func (sCmd *SnapshotCommand) RunCommand(cmd *cobra.Command, args []string) error
if err := json.Unmarshal([]byte(result), &resp); err != nil {
return err
}
if resp.Code != "0" {
if resp.Code != SNAPSHOT_QUERY_CODE_SUCCESS {
return fmt.Errorf("get clone list fail, error code: %s", resp.Code)
}
if len(resp.Snapshots) == 0 {
if len(resp.Snapshots) == LENGTH_EMPTY {
break
}
for _, s := range resp.Snapshots {
Expand Down

0 comments on commit b3cde96

Please sign in to comment.