Skip to content

Commit

Permalink
Merge pull request #46 from ddymko/issue/45
Browse files Browse the repository at this point in the history
Object Storage get call empty struct
  • Loading branch information
ddymko authored Feb 24, 2020
2 parents e24c64f + 7fd23ab commit 195ba05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions object_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,14 @@ func (o *ObjectStorageServiceHandler) Get(ctx context.Context, id int) (*ObjectS
req.URL.RawQuery = q.Encode()
}

objectStorage := new(ObjectStorage)

err = o.client.DoWithContext(ctx, req, objectStorage)

objStorage := make(map[string]ObjectStorage)
err = o.client.DoWithContext(ctx, req, &objStorage)
if err != nil {
return nil, err
}

return objectStorage, nil
obj := objStorage[strconv.Itoa(id)]
return &obj, nil
}

// ListCluster returns back your object storage clusters.
Expand Down
2 changes: 1 addition & 1 deletion object_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestObjectStorageServiceHandler_Get(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1/objectstorage/list", func(writer http.ResponseWriter, request *http.Request) {
response := `{"SUBID": 1314217,"date_created": "2019-04-17 17:33:00","OBJSTORECLUSTERID": 1,"DCID": 1,"location": "New Jersey","label": "object1","status": "active","s3_hostname": "nj1.vultrobjects.com","s3_access_key": "abc1234","s3_secret_key": "def5678"}`
response := `{"1314217":{"SUBID": 1314217,"date_created": "2019-04-17 17:33:00","OBJSTORECLUSTERID": 1,"DCID": 1,"location": "New Jersey","label": "object1","status": "active","s3_hostname": "nj1.vultrobjects.com","s3_access_key": "abc1234","s3_secret_key": "def5678"}}`
fmt.Fprint(writer, response)
})

Expand Down

0 comments on commit 195ba05

Please sign in to comment.