Skip to content

Commit

Permalink
Update VolumeList() func to include zone (#4755)
Browse files Browse the repository at this point in the history
  • Loading branch information
SupriyaKasten committed Jan 16, 2019
1 parent c1f5a5a commit 27efe42
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/blockstorage/awsebs/awsebs.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (s *ebsStorage) volumeParse(ctx context.Context, volume interface{}) *block
}
}

func (s *ebsStorage) VolumesList(ctx context.Context, tags map[string]string) ([]*blockstorage.Volume, error) {
func (s *ebsStorage) VolumesList(ctx context.Context, tags map[string]string, zone string) ([]*blockstorage.Volume, error) {
var vols []*blockstorage.Volume
var fltrs []*ec2.Filter
dvi := &ec2.DescribeVolumesInput{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/blockstorage/blockstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ type Provider interface {
SnapshotGet(ctx context.Context, id string) (*Snapshot, error)
// Others
SetTags(ctx context.Context, resource interface{}, tags map[string]string) error
VolumesList(ctx context.Context, tags map[string]string) ([]*Volume, error)
VolumesList(ctx context.Context, tags map[string]string, zone string) ([]*Volume, error)
SnapshotsList(ctx context.Context, tags map[string]string) ([]*Snapshot, error)
}
11 changes: 10 additions & 1 deletion pkg/blockstorage/blockstorage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,21 @@ func (s *BlockStorageProviderSuite) TestSnapshotCopy(c *C) {

func (s *BlockStorageProviderSuite) testVolumesList(c *C) {
var tags map[string]string
var zone string
if s.provider.Type() == blockstorage.TypeGPD {
tags = map[string]string{"name": "*"}
} else {
tags = map[string]string{"status": "available"}
}
vols, err := s.provider.VolumesList(context.Background(), tags)
switch s.storageType {
case blockstorage.TypeGPD:
zone = "us-west1-b"
case blockstorage.TypeEBS:
zone = "us-west-2b"
case blockstorage.TypeAD:
zone = "centralus"
}
vols, err := s.provider.VolumesList(context.Background(), tags, zone)
c.Assert(err, IsNil)
c.Assert(vols, NotNil)
c.Assert(vols, FitsTypeOf, []*blockstorage.Volume{})
Expand Down
2 changes: 1 addition & 1 deletion pkg/testutil/mockblockstorage/mockblockstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (p *Provider) MockSnapshot() *blockstorage.Snapshot {
}

// VolumesList mock
func (p *Provider) VolumesList(ctx context.Context, tags map[string]string) ([]*blockstorage.Volume, error) {
func (p *Provider) VolumesList(ctx context.Context, tags map[string]string, zone string) ([]*blockstorage.Volume, error) {
return []*blockstorage.Volume{p.MockVolume(), p.MockVolume()}, nil
}

Expand Down

0 comments on commit 27efe42

Please sign in to comment.