Skip to content

Commit f6cd0ba

Browse files
authored
Merge pull request #1160 from k8up-io/fix/s3-trailing-slash-1038
Fix trailing slash in S3 endpoint causing empty bucket name
2 parents 7dff5c1 + 7be32a1 commit f6cd0ba

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

api/v1/backend.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ func (in *S3Spec) String() string {
135135
if in.Endpoint != "" {
136136
endpoint = in.Endpoint
137137
}
138+
endpoint = strings.TrimRight(endpoint, "/")
138139

139140
bucket := cfg.Config.GlobalS3Bucket
140141
if in.Bucket != "" {

api/v1/backend_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ var tests = map[string]struct {
9696
},
9797
expectedRepositoryString: "s3:https://endpoint/bucket",
9898
},
99+
"GivenS3BackendWithTrailingSlash_ThenExpectCleanEndpointURL": {
100+
givenBackend: &Backend{
101+
S3: &S3Spec{
102+
Bucket: "bucket",
103+
Endpoint: "https://endpoint/",
104+
SecretAccessKeySecretRef: newSecretRef("secret"),
105+
AccessKeyIDSecretRef: newSecretRef("id"),
106+
},
107+
},
108+
expectedVars: map[string]*corev1.EnvVarSource{
109+
cfg.AwsAccessKeyIDEnvName: {SecretKeyRef: newSecretRef("id")},
110+
cfg.AwsSecretAccessKeyEnvName: {SecretKeyRef: newSecretRef("secret")},
111+
},
112+
expectedRepositoryString: "s3:https://endpoint/bucket",
113+
},
99114
"GivenSwiftBackend_ThenExpectSwiftBucket": {
100115
givenBackend: &Backend{
101116
Swift: &SwiftSpec{

0 commit comments

Comments
 (0)