@@ -18,7 +18,8 @@ import (
18
18
"golang.org/x/xerrors"
19
19
20
20
validation "github.com/go-ozzo/ozzo-validation"
21
- minio "github.com/minio/minio-go/v6"
21
+ minio "github.com/minio/minio-go/v7"
22
+ "github.com/minio/minio-go/v7/pkg/credentials"
22
23
)
23
24
24
25
var _ DirectAccess = & DirectMinIOStorage {}
@@ -57,7 +58,10 @@ func (c *MinIOConfig) MinIOClient() (*minio.Client, error) {
57
58
return nil , err
58
59
}
59
60
60
- minioClient , err := minio .New (c .Endpoint , c .AccessKeyID , c .SecretAccessKey , c .Secure )
61
+ minioClient , err := minio .New (c .Endpoint , & minio.Options {
62
+ Creds : credentials .NewStaticV4 (c .AccessKeyID , c .SecretAccessKey , "" ),
63
+ Secure : c .Secure ,
64
+ })
61
65
if err != nil {
62
66
return nil , err
63
67
}
@@ -125,7 +129,7 @@ func (rs *DirectMinIOStorage) defaultObjectAccess(ctx context.Context, bkt, obj
125
129
return nil , xerrors .Errorf ("no MinIO client avialable - did you call Init()?" )
126
130
}
127
131
128
- object , err := rs .client .GetObjectWithContext (ctx , bkt , obj , minio.GetObjectOptions {})
132
+ object , err := rs .client .GetObject (ctx , bkt , obj , minio.GetObjectOptions {})
129
133
if err != nil {
130
134
return nil , translateMinioError (err )
131
135
}
@@ -147,7 +151,7 @@ func (rs *DirectMinIOStorage) EnsureExists(ctx context.Context) (err error) {
147
151
return xerrors .Errorf ("no MinIO client avialable - did you call Init()?" )
148
152
}
149
153
150
- exists , err := rs .client .BucketExists (rs .bucketName ())
154
+ exists , err := rs .client .BucketExists (ctx , rs .bucketName ())
151
155
if err != nil {
152
156
return err
153
157
}
@@ -157,7 +161,7 @@ func (rs *DirectMinIOStorage) EnsureExists(ctx context.Context) (err error) {
157
161
}
158
162
159
163
log .WithField ("bucketName" , rs .bucketName ()).Debug ("Creating bucket" )
160
- err = rs .client .MakeBucket (rs .bucketName (), rs .MinIOConfig .Region )
164
+ err = rs .client .MakeBucket (ctx , rs .bucketName (), minio. MakeBucketOptions { Region : rs .MinIOConfig .Region } )
161
165
if err != nil {
162
166
return xerrors .Errorf ("cannot create bucket: %w" , err )
163
167
}
@@ -224,7 +228,7 @@ func (rs *DirectMinIOStorage) Upload(ctx context.Context, source string, name st
224
228
// upload the thing
225
229
bucket = rs .bucketName ()
226
230
obj = rs .objectName (name )
227
- _ , err = rs .client .FPutObjectWithContext (ctx , bucket , obj , source , minio.PutObjectOptions {
231
+ _ , err = rs .client .FPutObject (ctx , bucket , obj , source , minio.PutObjectOptions {
228
232
NumThreads : rs .MinIOConfig .ParallelUpload ,
229
233
UserMetadata : options .Annotations ,
230
234
ContentType : options .ContentType ,
@@ -283,15 +287,15 @@ func (s *presignedMinIOStorage) SignDownload(ctx context.Context, bucket, object
283
287
tracing .FinishSpan (span , & err )
284
288
}()
285
289
286
- obj , err := s .client .GetObject (bucket , object , minio.GetObjectOptions {})
290
+ obj , err := s .client .GetObject (ctx , bucket , object , minio.GetObjectOptions {})
287
291
if err != nil {
288
292
return nil , translateMinioError (err )
289
293
}
290
294
stat , err := obj .Stat ()
291
295
if err != nil {
292
296
return nil , translateMinioError (err )
293
297
}
294
- url , err := s .client .PresignedGetObject (bucket , object , 30 * time .Minute , nil )
298
+ url , err := s .client .PresignedGetObject (ctx , bucket , object , 30 * time .Minute , nil )
295
299
if err != nil {
296
300
return nil , translateMinioError (err )
297
301
}
0 commit comments