Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Commit 675ee63

Browse files
authored
Merge pull request #1873 from tjamet/s3-url
Migrate to new s3 URL method
2 parents f2781f8 + f553e94 commit 675ee63

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

pkg/api/assets.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package api
22

33
import (
44
"fmt"
5-
"github.com/kubernetes-incubator/kube-aws/fingerprint"
65
"strings"
6+
7+
"github.com/kubernetes-incubator/kube-aws/fingerprint"
78
)
89

910
type AssetID struct {
@@ -35,7 +36,7 @@ func (l AssetLocation) URL() (string, error) {
3536
if (l == AssetLocation{}) {
3637
return "", fmt.Errorf("[bug] Empty asset location can't have URL")
3738
}
38-
return fmt.Sprintf("%s/%s/%s", l.Region.S3Endpoint(), l.Bucket, l.Key), nil
39+
return fmt.Sprintf("%s/%s", l.Region.S3Endpoint(l.Bucket), l.Key), nil
3940
}
4041

4142
func (l AssetLocation) S3URL() (string, error) {

pkg/api/region.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ func (r Region) String() string {
4242
return r.Name
4343
}
4444

45-
func (r Region) S3Endpoint() string {
45+
func (r Region) S3Endpoint(bucket string) string {
46+
domain := "s3"
4647
if r.IsChina() {
47-
return fmt.Sprintf("https://s3.%s.amazonaws.com.cn", r.Name)
48+
domain = fmt.Sprintf("s3.%s", r.Name)
4849
}
4950
if r.IsGovcloud() {
50-
return fmt.Sprintf("https://s3-%s.amazonaws.com", r.Name)
51+
domain = fmt.Sprintf("s3-%s", r.Name)
5152
}
52-
return "https://s3.amazonaws.com"
53+
return fmt.Sprintf("https://%s.%s.%s", bucket, domain, r.PublicDomainName())
5354
}
5455

5556
func (r Region) Partition() string {

0 commit comments

Comments
 (0)