Skip to content

Commit db5eb25

Browse files
author
Aaron Schlesinger
committed
fix(pkg/gitreceive): pass the endpoint around, not the string URL
1 parent 473d769 commit db5eb25

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

pkg/gitreceive/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func build(conf *Config, s3Client *storage.Client, kubeClient *client.Client, fs
6363
return fmt.Errorf("unable to create tmpdir %s (%s)", buildDir, err)
6464
}
6565

66-
slugBuilderInfo := storage.NewSlugBuilderInfo(s3Client.Endpoint.URLStr, conf.Bucket, appName, slugName, gitSha)
66+
slugBuilderInfo := storage.NewSlugBuilderInfo(s3Client.Endpoint, conf.Bucket, appName, slugName, gitSha)
6767

6868
// Get the application config from the controller, so we can check for a custom buildpack URL
6969
appConf, err := getAppConfig(conf, builderKey, conf.Username, appName)

pkg/gitreceive/storage/slug_builder_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ type SlugBuilderInfo struct {
1515
}
1616

1717
// NewSlugBuilderInfo creates and populates a new SlugBuilderInfo based on the given data
18-
func NewSlugBuilderInfo(s3Endpoint, bucket, appName, slugName string, gitSha *git.SHA) *SlugBuilderInfo {
18+
func NewSlugBuilderInfo(s3Endpoint *Endpoint, bucket, appName, slugName string, gitSha *git.SHA) *SlugBuilderInfo {
1919
tarKey := fmt.Sprintf("home/%s/tar", slugName)
2020
// this is where workflow tells slugrunner to download the slug from, so we have to tell slugbuilder to upload it to here
2121
pushKey := fmt.Sprintf("home/%s:git-%s/push", appName, gitSha.Short())
2222

2323
return &SlugBuilderInfo{
2424
pushKey: pushKey,
25-
pushURL: fmt.Sprintf("%s/%s/%s", s3Endpoint, bucket, pushKey),
25+
pushURL: fmt.Sprintf("%s/%s/%s", s3Endpoint.FullURL(), bucket, pushKey),
2626
tarKey: tarKey,
27-
tarURL: fmt.Sprintf("%s/%s/%s", s3Endpoint, bucket, tarKey),
27+
tarURL: fmt.Sprintf("%s/%s/%s", s3Endpoint.FullURL(), bucket, tarKey),
2828
}
2929
}
3030

pkg/gitreceive/storage/slug_builder_info_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import (
77
)
88

99
const (
10-
rawSha = "c3b4e4ba8b7267226ff02ad07a3a2cca9c9237de"
11-
s3Endpoint = "http://10.1.2.3:9090"
12-
appName = "myapp"
13-
slugName = "myslug"
14-
bucket = "git"
10+
rawSha = "c3b4e4ba8b7267226ff02ad07a3a2cca9c9237de"
11+
appName = "myapp"
12+
slugName = "myslug"
13+
bucket = "git"
14+
)
15+
16+
var (
17+
s3Endpoint = &Endpoint{URLStr: "10.1.2.3:9090", Secure: false}
1518
)
1619

1720
func TestS3Endpoint(t *testing.T) {
@@ -21,11 +24,11 @@ func TestS3Endpoint(t *testing.T) {
2124
}
2225
sbi := NewSlugBuilderInfo(s3Endpoint, bucket, appName, slugName, sha)
2326

24-
expectedPushURL := s3Endpoint + "/" + bucket + "/" + sbi.PushKey()
27+
expectedPushURL := s3Endpoint.FullURL() + "/" + bucket + "/" + sbi.PushKey()
2528
if sbi.PushURL() != expectedPushURL {
2629
t.Errorf("push URL %s didn't match expected %s", sbi.PushURL(), expectedPushURL)
2730
}
28-
expectedTarURL := s3Endpoint + "/" + bucket + "/" + sbi.TarKey()
31+
expectedTarURL := s3Endpoint.FullURL() + "/" + bucket + "/" + sbi.TarKey()
2932
if sbi.TarURL() != expectedTarURL {
3033
t.Errorf("tar URL %s didn't match expected %s", sbi.TarURL(), expectedTarURL)
3134
}

0 commit comments

Comments
 (0)