Skip to content
This repository has been archived by the owner on Oct 15, 2021. It is now read-only.

storage: Implement AOS-40 #68

Merged
merged 1 commit into from
Apr 24, 2021
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
48 changes: 34 additions & 14 deletions generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.14

require (
github.com/aos-dev/go-integration-test/v3 v3.0.0-20210205075620-0b779f4b3afc
github.com/aos-dev/go-storage/v3 v3.5.1-0.20210421092104-4de248aed1f1
github.com/aos-dev/go-storage/v3 v3.5.1-0.20210423112617-6847a93345fd
github.com/aws/aws-sdk-go v1.38.24
github.com/google/uuid v1.2.0
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
github.com/Xuanwo/templateutils v0.0.0-20201019101431-c73b871118f2/go.mod h1:x0qS7gfgEm24b8V9U+0zBEBAu/VpxZhO/+EWtpgEgDw=
github.com/Xuanwo/templateutils v0.0.0-20201216100309-46f73cd4e4b1 h1:SQ8kQujQ0yl39YBMU0xZ+yyfxx/qSWfGWlCPNzHp5kw=
github.com/Xuanwo/templateutils v0.0.0-20201216100309-46f73cd4e4b1/go.mod h1:x0qS7gfgEm24b8V9U+0zBEBAu/VpxZhO/+EWtpgEgDw=
github.com/Xuanwo/templateutils v0.1.0 h1:WpkWOqQtIQ2vAIpJLa727DdN8WtxhUkkbDGa6UhntJY=
github.com/Xuanwo/templateutils v0.1.0/go.mod h1:OdE0DJ+CJxDBq6psX5DPV+gOZi8bhuHuVUpPCG++Wb8=
github.com/aos-dev/go-integration-test/v3 v3.0.0-20210205075620-0b779f4b3afc h1:s8BQqJwWe2yoTGJFOsIxnkwwMsnDqMgkO39yzEP4smw=
github.com/aos-dev/go-integration-test/v3 v3.0.0-20210205075620-0b779f4b3afc/go.mod h1:2VqxZhJVvI1jKTTERWHfCBMZQaJt10xoEJ+CxbfYZlo=
github.com/aos-dev/go-storage/v3 v3.0.1-0.20210205074802-e8a5b22166c2/go.mod h1:JznhvyhPDnETfZ3RyWm3mT/S5ic+uuYFWagSIkUZujc=
github.com/aos-dev/go-storage/v3 v3.5.1-0.20210421092104-4de248aed1f1 h1:Kkb/cVJRwc77lXGcnV2ThUC4QUqybiEVrFwq8qnM4V4=
github.com/aos-dev/go-storage/v3 v3.5.1-0.20210421092104-4de248aed1f1/go.mod h1:JFshvl851ZDDXtFGWDFKqkg34QEPH0xuhLJ2LjikZYc=
github.com/aos-dev/go-storage/v3 v3.5.1-0.20210423112617-6847a93345fd h1:FEBrz+fo4V+6jMxnbmkI0M+3m5MYriF5SijFF/Sz5cM=
github.com/aos-dev/go-storage/v3 v3.5.1-0.20210423112617-6847a93345fd/go.mod h1:ZQwybmoCcTWUOWg+G15gT/NQJoI8G8KH1pF41TuJqYk=
github.com/aos-dev/specs/go v0.0.0-20210205073047-af8ef94af73d/go.mod h1:XTNlLZtPA1inITyDH5hNnQXVjvvKUvo+lurs5GYB8NA=
github.com/aos-dev/specs/go v0.0.0-20210420062803-1a60efa2eae3 h1:LiW0Ki0Gw6opu11JwMhxWw5M+V6I9JypJ5eAIp+Rqt4=
github.com/aos-dev/specs/go v0.0.0-20210420062803-1a60efa2eae3/go.mod h1:gNah3KaPJEfysh7uCCX+sYjQC3g2yx2VgBkFlT945Ws=
github.com/aos-dev/specs/go v0.0.0-20210423110314-8361397c2bf3 h1:e65ozDhdfHfhnDpZF9SLcY5mwtAg/sAvNIUAkFd+4D0=
github.com/aos-dev/specs/go v0.0.0-20210423110314-8361397c2bf3/go.mod h1:gNah3KaPJEfysh7uCCX+sYjQC3g2yx2VgBkFlT945Ws=
github.com/aws/aws-sdk-go v1.38.24 h1:zbKHDxFepE77ihVMZ+wZ62Ci646zkorN8rB5s4fj4kU=
github.com/aws/aws-sdk-go v1.38.24/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/dave/dst v0.26.2 h1:lnxLAKI3tx7MgLNVDirFCsDTlTG9nKTk7GcptKcWSwY=
Expand Down
2 changes: 1 addition & 1 deletion service.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ type = "string"
type = "string"

[infos.object.meta.server-side-encryption-bucket-key-enabled]
type = "string"
type = "bool"
33 changes: 16 additions & 17 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import (
"context"
"encoding/base64"
"fmt"
"io"
"strconv"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/s3"
"io"

"github.com/aos-dev/go-storage/v3/pkg/iowrap"
. "github.com/aos-dev/go-storage/v3/types"
Expand Down Expand Up @@ -93,24 +91,24 @@ func (s *Storage) createMultipart(ctx context.Context, path string, opt pairStor
o.Mode |= ModePart
o.SetMultipartID(aws.StringValue(output.UploadId))

sm := make(map[string]string)
var sm ObjectMetadata
if v := aws.StringValue(output.ServerSideEncryption); v != "" {
sm[MetadataServerSideEncryption] = v
sm.ServerSideEncryption = v
}
if v := aws.StringValue(output.SSEKMSKeyId); v != "" {
sm[MetadataServerSideEncryptionAwsKmsKeyID] = v
sm.ServerSideEncryptionAwsKmsKeyID = v
}
if v := aws.StringValue(output.SSEKMSEncryptionContext); v != "" {
sm[MetadataServerSideEncryptionContext] = v
sm.ServerSideEncryptionContext = v
}
if v := aws.StringValue(output.SSECustomerAlgorithm); v != "" {
sm[MetadataServerSideEncryptionCustomerAlgorithm] = v
sm.ServerSideEncryptionCustomerAlgorithm = v
}
if v := aws.StringValue(output.SSECustomerKeyMD5); v != "" {
sm[MetadataServerSideEncryptionCustomerKeyMd5] = v
sm.ServerSideEncryptionCustomerKeyMd5 = v
}
if output.BucketKeyEnabled != nil {
sm[MetadataServerSideEncryptionBucketKeyEnabled] = strconv.FormatBool(aws.BoolValue(output.BucketKeyEnabled))
sm.ServerSideEncryptionBucketKeyEnabled = aws.BoolValue(output.BucketKeyEnabled)
}

o.SetServiceMetadata(sm)
Expand Down Expand Up @@ -424,24 +422,25 @@ func (s *Storage) stat(ctx context.Context, path string, opt pairStorageStat) (o
if output.ETag != nil {
o.SetEtag(*output.ETag)
}
sm := make(map[string]string)

var sm ObjectMetadata
if v := aws.StringValue(output.StorageClass); v != "" {
sm[MetadataStorageClass] = v
sm.StorageClass = v
}
if v := aws.StringValue(output.ServerSideEncryption); v != "" {
sm[MetadataServerSideEncryption] = v
sm.ServerSideEncryption = v
}
if v := aws.StringValue(output.SSEKMSKeyId); v != "" {
sm[MetadataServerSideEncryptionAwsKmsKeyID] = v
sm.ServerSideEncryptionAwsKmsKeyID = v
}
if v := aws.StringValue(output.SSECustomerAlgorithm); v != "" {
sm[MetadataServerSideEncryptionCustomerAlgorithm] = v
sm.ServerSideEncryptionCustomerAlgorithm = v
}
if v := aws.StringValue(output.SSECustomerKeyMD5); v != "" {
sm[MetadataServerSideEncryptionCustomerKeyMd5] = v
sm.ServerSideEncryptionCustomerKeyMd5 = v
}
if output.BucketKeyEnabled != nil {
sm[MetadataServerSideEncryptionBucketKeyEnabled] = strconv.FormatBool(aws.BoolValue(output.BucketKeyEnabled))
sm.ServerSideEncryptionBucketKeyEnabled = aws.BoolValue(output.BucketKeyEnabled)
}
o.SetServiceMetadata(sm)

Expand Down
4 changes: 2 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ func (s *Storage) formatFileObject(v *s3.Object) (o *typ.Object, err error) {
o.SetEtag(*v.ETag)
}

sm := make(map[string]string)
var sm ObjectMetadata
if value := aws.StringValue(v.StorageClass); value != "" {
sm[MetadataStorageClass] = value
sm.StorageClass = value
}
o.SetServiceMetadata(sm)

Expand Down