|
1 | 1 | package healthsrv |
2 | 2 |
|
3 | 3 | import ( |
4 | | - s3 "github.com/aws/aws-sdk-go/service/s3" |
| 4 | + s3 "github.com/minio/minio-go" |
5 | 5 | ) |
6 | 6 |
|
7 | 7 | // BucketLister is a *(github.com/aws/aws-sdk-go/service/s3).Client compatible interface that provides just the ListBuckets cross-section of functionality. It can also be implemented for unit tests |
8 | 8 | type BucketLister interface { |
9 | 9 | // ListBuckets lists all the buckets in the object storage system |
10 | | - ListBuckets(*s3.ListBucketsInput) (*s3.ListBucketsOutput, error) |
| 10 | + ListBuckets() ([]s3.BucketInfo, error) |
11 | 11 | } |
12 | 12 |
|
13 | 13 | type emptyBucketLister struct{} |
14 | 14 |
|
15 | | -func (e emptyBucketLister) ListBuckets(*s3.ListBucketsInput) (*s3.ListBucketsOutput, error) { |
16 | | - var buckets []*s3.Bucket |
17 | | - return &s3.ListBucketsOutput{Buckets: buckets}, nil |
| 15 | +func (e emptyBucketLister) ListBuckets() ([]s3.BucketInfo, error) { |
| 16 | + return nil, nil |
18 | 17 | } |
19 | 18 |
|
20 | 19 | type errBucketLister struct { |
21 | 20 | err error |
22 | 21 | } |
23 | 22 |
|
24 | | -func (e errBucketLister) ListBuckets(*s3.ListBucketsInput) (*s3.ListBucketsOutput, error) { |
| 23 | +func (e errBucketLister) ListBuckets() ([]s3.BucketInfo, error) { |
25 | 24 | return nil, e.err |
26 | 25 | } |
27 | 26 |
|
28 | 27 | // listBuckets calls bl.ListBuckets(...) and sends the results back on the various given channels. This func is intended to be run in a goroutine and communicates via the channels it's passed. |
29 | 28 | // |
30 | 29 | // On success, it passes the bucket output on succCh, and on failure, it passes the error on errCh. At most one of {succCh, errCh} will be sent on. If stopCh is closed, no pending or future sends will occur. |
31 | | -func listBuckets(bl BucketLister, succCh chan<- *s3.ListBucketsOutput, errCh chan<- error, stopCh <-chan struct{}) { |
32 | | - lbOut, err := bl.ListBuckets(&s3.ListBucketsInput{}) |
| 30 | +func listBuckets(bl BucketLister, succCh chan<- []s3.BucketInfo, errCh chan<- error, stopCh <-chan struct{}) { |
| 31 | + lbOut, err := bl.ListBuckets() |
33 | 32 | if err != nil { |
34 | 33 | select { |
35 | 34 | case errCh <- err: |
|
0 commit comments