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

fix: 增加对 aliyun oss 的支持||fix: Added support for Aliyun OSS #1069

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions components/oss/aliyun/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ func (a *AliyunOSS) ListObjects(ctx context.Context, req *l8oss.ListObjectsInput
object := &l8oss.Object{
ETag: v.ETag,
Key: v.Key,
Type: v.Type,
LastModified: v.LastModified.Unix(),
Owner: &l8oss.Owner{ID: v.Owner.ID, DisplayName: v.Owner.DisplayName},
Size: v.Size,
Expand Down
2 changes: 2 additions & 0 deletions components/oss/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ type ListObjectsInput struct {
MaxKeys int32 `json:"maxKeys,omitempty"`
Prefix string `json:"prefix,omitempty"`
RequestPayer string `json:"request_payer,omitempty"`
FetchOwner bool `json:"fetch_owner,omitempty"`
}
type ListObjectsOutput struct {
CommonPrefixes []string `json:"common_prefixes,omitempty"`
Expand All @@ -254,6 +255,7 @@ type Object struct {
Owner *Owner `json:"owner,omitempty"`
Size int64 `json:"size,omitempty"`
StorageClass string `json:"storage_class,omitempty"`
Type string `json:"type,omitempty"`
}
type Owner struct {
DisplayName string `json:"display_name,omitempty"`
Expand Down
36 changes: 36 additions & 0 deletions pkg/grpc/extension/s3/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ func TestListObjects(t *testing.T) {
MaxKeys: 1,
Prefix: "Prefix",
RequestPayer: "RequestPayer",
FetchOwner: true,
}
_, err := s3Server.ListObjects(ctx, req)
assert.Equal(t, status.Errorf(codes.InvalidArgument, NotSupportStoreName, "NoStore"), err)
Expand All @@ -354,13 +355,48 @@ func TestListObjects(t *testing.T) {
MaxKeys: 1,
Prefix: "Prefix",
RequestPayer: "RequestPayer",
FetchOwner: true,
},
).Return(output, nil)
req.StoreName = MOCKSERVER
resp, err := s3Server.ListObjects(ctx, req)
assert.Nil(t, err)
assert.Equal(t, true, resp.IsTruncated)
assert.Equal(t, "delimiter", resp.Delimiter)

ctx = context.TODO()
req = &s3.ListObjectsInput{
StoreName: "NoStore",
Bucket: "layotto",
Delimiter: "delimiter",
EncodingType: "EncodingType",
ExpectedBucketOwner: "ExpectedBucketOwner",
Marker: "Marker",
MaxKeys: 1,
Prefix: "Prefix",
RequestPayer: "RequestPayer",
}
_, err = s3Server.ListObjects(ctx, req)
assert.Equal(t, status.Errorf(codes.InvalidArgument, NotSupportStoreName, "NoStore"), err)
output = &l8s3.ListObjectsOutput{Delimiter: "delimiter", IsTruncated: true}
mockossServer.EXPECT().ListObjects(ctx,
&l8s3.ListObjectsInput{
Bucket: "layotto",
Delimiter: "delimiter",
EncodingType: "EncodingType",
ExpectedBucketOwner: "ExpectedBucketOwner",
Marker: "Marker",
MaxKeys: 1,
Prefix: "Prefix",
RequestPayer: "RequestPayer",
FetchOwner: false,
},
).Return(output, nil)
req.StoreName = MOCKSERVER
resp, err = s3Server.ListObjects(ctx, req)
assert.Nil(t, err)
assert.Equal(t, true, resp.IsTruncated)
assert.Equal(t, "delimiter", resp.Delimiter)
}

// TestGetObjectCannedAcl
Expand Down
Loading
Loading