api: upgrade to minio-go v7.0.1 (#3306)
This commit is contained in:
+23
-24
@@ -133,20 +133,6 @@ func newFactory() func(config *Config) (Client, *probe.Error) {
|
||||
if strings.ToUpper(config.Signature) == "S3V2" {
|
||||
creds = credentials.NewStaticV2(config.AccessKey, config.SecretKey, "")
|
||||
}
|
||||
// Not found. Instantiate a new MinIO
|
||||
var e error
|
||||
|
||||
options := minio.Options{
|
||||
Creds: creds,
|
||||
Secure: useTLS,
|
||||
Region: "",
|
||||
BucketLookup: config.Lookup,
|
||||
}
|
||||
|
||||
api, e = minio.NewWithOptions(hostName, &options)
|
||||
if e != nil {
|
||||
return nil, probe.NewError(e)
|
||||
}
|
||||
|
||||
tr := &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
@@ -200,8 +186,21 @@ func newFactory() func(config *Config) (Client, *probe.Error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Set the new transport.
|
||||
api.SetCustomTransport(transport)
|
||||
// Not found. Instantiate a new MinIO
|
||||
var e error
|
||||
|
||||
options := minio.Options{
|
||||
Creds: creds,
|
||||
Secure: useTLS,
|
||||
Region: "",
|
||||
BucketLookup: config.Lookup,
|
||||
Transport: transport,
|
||||
}
|
||||
|
||||
api, e = minio.New(hostName, &options)
|
||||
if e != nil {
|
||||
return nil, probe.NewError(e)
|
||||
}
|
||||
|
||||
// If Amazon Accelerated URL is requested enable it.
|
||||
if isS3AcceleratedEndpoint {
|
||||
@@ -1046,16 +1045,16 @@ func (c *S3Client) Put(ctx context.Context, reader io.Reader, size int64, metada
|
||||
}
|
||||
|
||||
// Remove incomplete uploads.
|
||||
func (c *S3Client) removeIncompleteObjects(ctx context.Context, bucket string, objectsCh <-chan string) <-chan minio.RemoveObjectError {
|
||||
func (c *S3Client) removeIncompleteObjects(ctx context.Context, bucket string, objectsCh <-chan minio.ObjectInfo) <-chan minio.RemoveObjectError {
|
||||
removeObjectErrorCh := make(chan minio.RemoveObjectError)
|
||||
|
||||
// Goroutine reads from objectsCh and sends error to removeObjectErrorCh if any.
|
||||
go func() {
|
||||
defer close(removeObjectErrorCh)
|
||||
|
||||
for object := range objectsCh {
|
||||
if err := c.api.RemoveIncompleteUpload(ctx, bucket, object); err != nil {
|
||||
removeObjectErrorCh <- minio.RemoveObjectError{ObjectName: object, Err: err}
|
||||
for info := range objectsCh {
|
||||
if err := c.api.RemoveIncompleteUpload(ctx, bucket, info.Key); err != nil {
|
||||
removeObjectErrorCh <- minio.RemoveObjectError{ObjectName: info.Key, Err: err}
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -1074,7 +1073,7 @@ func (c *S3Client) Remove(ctx context.Context, isIncomplete, isRemoveBucket, isB
|
||||
|
||||
prevBucket := ""
|
||||
// Maintain objectsCh, statusCh for each bucket
|
||||
var objectsCh chan string
|
||||
var objectsCh chan minio.ObjectInfo
|
||||
var statusCh <-chan minio.RemoveObjectError
|
||||
opts := minio.RemoveObjectsOptions{
|
||||
GovernanceBypass: isBypass,
|
||||
@@ -1100,7 +1099,7 @@ func (c *S3Client) Remove(ctx context.Context, isIncomplete, isRemoveBucket, isB
|
||||
|
||||
// Init objectsCh the first time.
|
||||
if prevBucket == "" {
|
||||
objectsCh = make(chan string)
|
||||
objectsCh = make(chan minio.ObjectInfo)
|
||||
prevBucket = bucket
|
||||
if isIncomplete {
|
||||
statusCh = c.removeIncompleteObjects(ctx, bucket, objectsCh)
|
||||
@@ -1123,7 +1122,7 @@ func (c *S3Client) Remove(ctx context.Context, isIncomplete, isRemoveBucket, isB
|
||||
}
|
||||
}
|
||||
// Re-init objectsCh for next bucket
|
||||
objectsCh = make(chan string)
|
||||
objectsCh = make(chan minio.ObjectInfo)
|
||||
if isIncomplete {
|
||||
statusCh = c.removeIncompleteObjects(ctx, bucket, objectsCh)
|
||||
} else {
|
||||
@@ -1139,7 +1138,7 @@ func (c *S3Client) Remove(ctx context.Context, isIncomplete, isRemoveBucket, isB
|
||||
sent := false
|
||||
for !sent {
|
||||
select {
|
||||
case objectsCh <- objectName:
|
||||
case objectsCh <- minio.ObjectInfo{Key: objectName}:
|
||||
sent = true
|
||||
case removeStatus := <-statusCh:
|
||||
errorCh <- probe.NewError(removeStatus.Err)
|
||||
|
||||
@@ -13,7 +13,7 @@ require (
|
||||
github.com/mattn/go-isatty v0.0.8
|
||||
github.com/minio/cli v1.22.0
|
||||
github.com/minio/minio v0.0.0-20200714163805-778e9c864f67
|
||||
github.com/minio/minio-go/v7 v7.0.0-20200717002236-16b4b137ee4b
|
||||
github.com/minio/minio-go/v7 v7.0.1
|
||||
github.com/minio/sha256-simd v0.1.1
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
|
||||
|
||||
@@ -279,8 +279,8 @@ github.com/minio/minio v0.0.0-20200714163805-778e9c864f67 h1:xMg87xvLhrw2jeE6xGx
|
||||
github.com/minio/minio v0.0.0-20200714163805-778e9c864f67/go.mod h1:0WThPBMICOt5eEGT3XyaUy0cxYmoGhmJEvvRbiVqbYU=
|
||||
github.com/minio/minio-go/v7 v7.0.0-20200714085548-47e386e2cde8 h1:Xh5yHlXj/367YMabi7tWHol1AslXcuAFWaedBtGgbU0=
|
||||
github.com/minio/minio-go/v7 v7.0.0-20200714085548-47e386e2cde8/go.mod h1:QTstSRgetEDVpqiEpFniLoCslH4d9cNAa4BtjuRQrwE=
|
||||
github.com/minio/minio-go/v7 v7.0.0-20200717002236-16b4b137ee4b h1:aNa+ApHn0FYMFdwfI9IqLFLajN/FoHpqLdN20emn+Ck=
|
||||
github.com/minio/minio-go/v7 v7.0.0-20200717002236-16b4b137ee4b/go.mod h1:dJ80Mv2HeGkYLH1sqS/ksz07ON6csH3S6JUMSQ2zAns=
|
||||
github.com/minio/minio-go/v7 v7.0.1 h1:sL2y4uuNUEi7AjvWjoGyDFQKFX2zA0DU2tGM9m3s5f8=
|
||||
github.com/minio/minio-go/v7 v7.0.1/go.mod h1:dJ80Mv2HeGkYLH1sqS/ksz07ON6csH3S6JUMSQ2zAns=
|
||||
github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU=
|
||||
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
|
||||
github.com/minio/simdjson-go v0.1.5-0.20200303142138-b17fe061ea37 h1:pDeao6M5AEd8hwTtGmE0pVKomlL56JFRa5SiXDZAuJE=
|
||||
|
||||
Reference in New Issue
Block a user