Skip to content

Commit 8e8760b

Browse files
authored
Merge pull request #28 from gig-tech/disk
improve disk data source
2 parents 0ae5e08 + 4554b9f commit 8e8760b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

ovc/disks.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ type DiskList []struct {
8989
// endpoints of the OVC API
9090
type DiskService interface {
9191
Resize(*DiskConfig) error
92-
List(int) (*DiskList, error)
92+
List(int, string) (*DiskList, error)
9393
Get(string) (*DiskInfo, error)
94-
GetByName(string, string) (*DiskInfo, error)
94+
GetByName(string, int, string) (*DiskInfo, error)
9595
Create(*DiskConfig) (string, error)
9696
CreateAndAttach(*DiskConfig) (string, error)
9797
Attach(*DiskAttachConfig) error
@@ -107,9 +107,12 @@ type DiskServiceOp struct {
107107
}
108108

109109
// List all disks
110-
func (s *DiskServiceOp) List(accountID int) (*DiskList, error) {
110+
func (s *DiskServiceOp) List(accountID int, diskType string) (*DiskList, error) {
111111
diskMap := make(map[string]interface{})
112112
diskMap["accountId"] = accountID
113+
if len(diskType) != 0 {
114+
diskMap["type"] = diskType
115+
}
113116
diskJSON, err := json.Marshal(diskMap)
114117
if err != nil {
115118
return nil, err
@@ -289,12 +292,8 @@ func (s *DiskServiceOp) Get(diskID string) (*DiskInfo, error) {
289292
}
290293

291294
// GetByName gets a disk by its name
292-
func (s *DiskServiceOp) GetByName(name string, accountID string) (*DiskInfo, error) {
293-
aid, err := strconv.Atoi(accountID)
294-
if err != nil {
295-
return nil, err
296-
}
297-
disks, err := s.client.Disks.List(aid)
295+
func (s *DiskServiceOp) GetByName(name string, accountID int, diskType string) (*DiskInfo, error) {
296+
disks, err := s.client.Disks.List(accountID, diskType)
298297
if err != nil {
299298
return nil, err
300299
}

0 commit comments

Comments
 (0)