Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3: exporting minio client #143

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions providers/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ type TraceConfig struct {
type Bucket struct {
logger log.Logger
name string
client *minio.Client
Client *minio.Client
defaultSSE encrypt.ServerSide
putUserMetadata map[string]string
storageClass string
Expand Down Expand Up @@ -329,7 +329,7 @@ func NewBucketWithConfig(logger log.Logger, config Config, component string) (*B
bkt := &Bucket{
logger: logger,
name: config.Bucket,
client: client,
Client: client,
defaultSSE: sse,
putUserMetadata: config.PutUserMetadata,
storageClass: storageClass,
Expand Down Expand Up @@ -400,7 +400,7 @@ func (b *Bucket) Iter(ctx context.Context, dir string, f func(string) error, opt
UseV1: b.listObjectsV1,
}

for object := range b.client.ListObjects(ctx, b.name, opts) {
for object := range b.Client.ListObjects(ctx, b.name, opts) {
// Catch the error when failed to list objects.
if object.Err != nil {
return object.Err
Expand Down Expand Up @@ -439,10 +439,10 @@ func (b *Bucket) getRange(ctx context.Context, name string, off, length int64) (
}

// StatObject to see if the object exists and we have permissions to read it
if _, err := b.client.StatObject(ctx, b.name, name, *opts); err != nil {
if _, err := b.Client.StatObject(ctx, b.name, name, *opts); err != nil {
return nil, err
}
return b.client.GetObject(ctx, b.name, name, *opts)
return b.Client.GetObject(ctx, b.name, name, *opts)
}

// Get returns a reader for the given object name.
Expand All @@ -457,7 +457,7 @@ func (b *Bucket) GetRange(ctx context.Context, name string, off, length int64) (

// Exists checks if the given object exists.
func (b *Bucket) Exists(ctx context.Context, name string) (bool, error) {
_, err := b.client.StatObject(ctx, b.name, name, minio.StatObjectOptions{})
_, err := b.Client.StatObject(ctx, b.name, name, minio.StatObjectOptions{})
if err != nil {
if b.IsObjNotFoundErr(err) {
return false, nil
Expand Down Expand Up @@ -493,7 +493,7 @@ func (b *Bucket) Upload(ctx context.Context, name string, r io.Reader) error {
userMetadata[k] = v
}

if _, err := b.client.PutObject(
if _, err := b.Client.PutObject(
ctx,
b.name,
name,
Expand All @@ -520,7 +520,7 @@ func (b *Bucket) Upload(ctx context.Context, name string, r io.Reader) error {

// Attributes returns information about the specified object.
func (b *Bucket) Attributes(ctx context.Context, name string) (objstore.ObjectAttributes, error) {
objInfo, err := b.client.StatObject(ctx, b.name, name, minio.StatObjectOptions{})
objInfo, err := b.Client.StatObject(ctx, b.name, name, minio.StatObjectOptions{})
if err != nil {
return objstore.ObjectAttributes{}, err
}
Expand All @@ -533,7 +533,7 @@ func (b *Bucket) Attributes(ctx context.Context, name string) (objstore.ObjectAt

// Delete removes the object with the given name.
func (b *Bucket) Delete(ctx context.Context, name string) error {
return b.client.RemoveObject(ctx, b.name, name, minio.RemoveObjectOptions{})
return b.Client.RemoveObject(ctx, b.name, name, minio.RemoveObjectOptions{})
}

// IsObjNotFoundErr returns true if error means that object is not found. Relevant to Get operations.
Expand Down Expand Up @@ -622,15 +622,15 @@ func NewTestBucketFromConfig(t testing.TB, location string, c Config, reuseBucke
bktToCreate = objstore.CreateTemporaryTestBucketName(t)
}

if err := b.client.MakeBucket(ctx, bktToCreate, minio.MakeBucketOptions{Region: location}); err != nil {
if err := b.Client.MakeBucket(ctx, bktToCreate, minio.MakeBucketOptions{Region: location}); err != nil {
return nil, nil, err
}
b.name = bktToCreate
t.Log("created temporary AWS bucket for AWS tests with name", bktToCreate, "in", location)

return b, func() {
objstore.EmptyBucket(t, ctx, b)
if err := b.client.RemoveBucket(ctx, bktToCreate); err != nil {
if err := b.Client.RemoveBucket(ctx, bktToCreate); err != nil {
t.Logf("deleting bucket %s failed: %s", bktToCreate, err)
}
}, nil
Expand Down
Loading