Skip to content

Commit dbd09b5

Browse files
committed
Bump version
1 parent 2555308 commit dbd09b5

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ require (
5858
google.golang.org/grpc v1.46.0 // indirect
5959
)
6060

61-
replace github.com/flyteorg/stow => github.com/ddl-rliu/stow v0.0.14
61+
replace github.com/flyteorg/stow => github.com/ddl-rliu/stow v0.0.15

s3/config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package s3
22

33
import (
4-
"log"
54
"net/http"
65
"net/url"
76
"time"
@@ -155,7 +154,6 @@ func newS3Client(config stow.Config, region string) (client *s3.S3, endpoint str
155154
awsConfig.WithRegion("us-east-1")
156155
}
157156

158-
log.Printf("role: %s // %s // %s", authType, accessKeyID, secretKey)
159157
if authType == authTypeAccessKey {
160158
awsConfig.WithCredentials(credentials.NewStaticCredentials(accessKeyID, secretKey, ""))
161159
}

s3/container.go

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package s3
22

33
import (
44
"context"
5+
"encoding/json"
56
"fmt"
67
"io"
78
"log"
@@ -29,6 +30,11 @@ type container struct {
2930
extraArgs string
3031
}
3132

33+
type S3ExtraArgs struct {
34+
ServerSideEncryption string
35+
SSEKMSKeyId string
36+
}
37+
3238
func (c *container) PreSignRequest(ctx context.Context, clientMethod stow.ClientMethod, id string,
3339
params stow.PresignRequestParams) (url string, err error) {
3440

@@ -52,19 +58,28 @@ func (c *container) PreSignRequest(ctx context.Context, clientMethod stow.Client
5258
}
5359
log.Printf("bucket: %s // %s", c.name, id)
5460
log.Printf("extra args: %s", c.extraArgs)
55-
if bucketEncrypted, sseAlgortihm, encryptionKey := getKmsMasterKeyId(c.client, c.name); bucketEncrypted {
56-
log.Printf("sse: %s // %s", sseAlgortihm, encryptionKey)
57-
// switch sseAlgortihm {
58-
// case s3.ServerSideEncryptionAes256:
59-
// params.ServerSideEncryption = aws.String(sseAlgortihm)
60-
// case s3.ServerSideEncryptionAwsKms:
61-
// params.ServerSideEncryption = aws.String(sseAlgortihm)
62-
// if encryptionKey != "" {
63-
// params.SSEKMSKeyId = aws.String(encryptionKey)
64-
// }
65-
// }
66-
params.ServerSideEncryption = aws.String("aws:kms")
67-
params.SSEKMSKeyId = aws.String("kmsId") // placeholder - i think the presigned-url setup means this dummy value is sufficient
61+
62+
// First, try to set SSE using stow.config
63+
var extraArgs S3ExtraArgs
64+
json.Unmarshal([]byte(c.extraArgs), &extraArgs)
65+
log.Printf("extra args: %s // %s", extraArgs.ServerSideEncryption, extraArgs.SSEKMSKeyId)
66+
67+
if extraArgs.ServerSideEncryption == "" {
68+
// As backup, try to set SSE using s3.GetBucketEncryption
69+
if bucketEncrypted, sseAlgortihm, encryptionKey := getKmsMasterKeyId(c.client, c.name); bucketEncrypted {
70+
log.Printf("sse: %s // %s", sseAlgortihm, encryptionKey)
71+
extraArgs.ServerSideEncryption, extraArgs.SSEKMSKeyId = sseAlgortihm, encryptionKey
72+
}
73+
}
74+
75+
switch extraArgs.ServerSideEncryption {
76+
case s3.ServerSideEncryptionAes256:
77+
params.ServerSideEncryption = aws.String(extraArgs.ServerSideEncryption)
78+
case s3.ServerSideEncryptionAwsKms:
79+
params.ServerSideEncryption = aws.String(extraArgs.ServerSideEncryption)
80+
if extraArgs.SSEKMSKeyId != "" {
81+
params.SSEKMSKeyId = aws.String(extraArgs.SSEKMSKeyId)
82+
}
6883
}
6984

7085
req, _ = c.client.PutObjectRequest(params)

0 commit comments

Comments
 (0)