Skip to content

Commit b3cde96

Browse files
committed
[fix] fix code review issues
1 parent 449d662 commit b3cde96

File tree

1 file changed

+9
-11
lines changed
  • tools-v2/pkg/cli/command/curvebs/status/volume/snapshot

1 file changed

+9
-11
lines changed

tools-v2/pkg/cli/command/curvebs/status/volume/snapshot/snapshot.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ type SnapshotInfoData struct {
6060
}
6161

6262
const (
63-
SNAPSHOT_SUBURI = "/SnapshotCloneService"
64-
ACTION_GET_FILE_SNAPSHOT_LIST = "GetFileSnapshotList"
65-
ENTRIES_PER_TIME = 100
63+
SNAPSHOT_QUERY_LIMIT = 100
64+
SNAPSHOT_QUERY_INITIAL_OFFSET = 0
65+
SNAPSHOT_QUERY_CODE_SUCCESS = "0"
66+
LENGTH_EMPTY = 0
6667
)
6768

6869
const (
@@ -114,7 +115,7 @@ func NewVolumeSnapshotCommand() *SnapshotCommand {
114115
vsCmd := &SnapshotCommand{
115116
FinalCurveCmd: basecmd.FinalCurveCmd{
116117
Use: "snapshot",
117-
Short: "create snapshot of curvebs volume",
118+
Short: "show the snapshot status",
118119
},
119120
}
120121
basecmd.NewFinalCurveCli(&vsCmd.FinalCurveCmd, vsCmd)
@@ -142,13 +143,10 @@ func (sCmd *SnapshotCommand) RunCommand(cmd *cobra.Command, args []string) error
142143
cobrautil.QueryAction: cobrautil.ActionGetFileSnapshotList,
143144
cobrautil.QueryUser: sCmd.user,
144145
cobrautil.QueryFile: sCmd.filename,
145-
cobrautil.QueryLimit: 100,
146-
cobrautil.QueryOffset: 0,
146+
cobrautil.QueryLimit: SNAPSHOT_QUERY_LIMIT,
147+
cobrautil.QueryOffset: SNAPSHOT_QUERY_INITIAL_OFFSET,
147148
}
148149
count := make(map[int]int)
149-
for _, s := range statusList {
150-
count[s] = 0
151-
}
152150
for {
153151
subUri := cobrautil.NewSnapshotQuerySubUri(params)
154152

@@ -162,10 +160,10 @@ func (sCmd *SnapshotCommand) RunCommand(cmd *cobra.Command, args []string) error
162160
if err := json.Unmarshal([]byte(result), &resp); err != nil {
163161
return err
164162
}
165-
if resp.Code != "0" {
163+
if resp.Code != SNAPSHOT_QUERY_CODE_SUCCESS {
166164
return fmt.Errorf("get clone list fail, error code: %s", resp.Code)
167165
}
168-
if len(resp.Snapshots) == 0 {
166+
if len(resp.Snapshots) == LENGTH_EMPTY {
169167
break
170168
}
171169
for _, s := range resp.Snapshots {

0 commit comments

Comments
 (0)