Skip to content
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
3 changes: 3 additions & 0 deletions pkg/controllers/common/fileservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ func sharedFileServiceConfig(sp v1alpha1.SharedStorageProvider, cache *v1alpha1.
// TODO: let AWS SDK discover its own endpoint by default
s3Config["endpoint"] = "s3.us-west-2.amazonaws.com"
}
if s3.Region != "" {
s3Config["region"] = s3.Region
}
paths := strings.SplitN(strings.Trim(s3.Path, "/"), "/", 2)
s3Config["bucket"] = paths[0]
keyPrefix := subDir
Expand Down
36 changes: 35 additions & 1 deletion pkg/controllers/common/fileservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ func TestFileServiceConfig(t *testing.T) {
localPath: "/test",
sp: v1alpha1.SharedStorageProvider{
S3: &v1alpha1.S3Provider{
Path: "bucket/prefix",
Path: "bucket/prefix",
Region: "ap-shanghai",
SecretRef: &corev1.LocalObjectReference{
Name: "aws",
},
Expand All @@ -62,6 +63,7 @@ func TestFileServiceConfig(t *testing.T) {
},
"s3": map[string]interface{}{
"endpoint": "s3.us-west-2.amazonaws.com",
"region": "ap-shanghai",
"key-prefix": "prefix/data",
"bucket": "bucket",
},
Expand All @@ -73,6 +75,7 @@ func TestFileServiceConfig(t *testing.T) {
},
"s3": map[string]interface{}{
"endpoint": "s3.us-west-2.amazonaws.com",
"region": "ap-shanghai",
"key-prefix": "prefix/etl",
"bucket": "bucket",
},
Expand Down Expand Up @@ -137,3 +140,34 @@ func TestFileServiceConfig(t *testing.T) {
})
}
}

func TestLogServiceFSConfigWithS3Region(t *testing.T) {
sp := v1alpha1.SharedStorageProvider{
S3: &v1alpha1.S3Provider{
Path: "bucket",
Region: "ap-shanghai",
},
}
want := map[string]interface{}{
"data-dir": "/test",
"fileservice": []map[string]interface{}{
{
"name": BackupFileServiceName,
"backend": fsBackendTypeS3,
"s3": map[string]interface{}{
"endpoint": "s3.us-west-2.amazonaws.com",
"region": "ap-shanghai",
"bucket": "bucket",
"key-prefix": "",
},
"cache": map[string]interface{}{
"memory-capacity": "1B",
},
},
},
}

if diff := cmp.Diff(want, LogServiceFSConfig("/test", sp)); diff != "" {
t.Errorf("LogServiceFSConfig(), diff:\n %s", diff)
}
}
Loading