Skip to content

Commit 5a069b0

Browse files
author
Aaron Schlesinger
committed
fix(pkg/gitreceive): look for the absolute location of the slug
this commit adds a convenience func in SlugBuilderInfo, tests for it, and changes the build func to use it. This commit also adds an AbsoluteSlugURL func to SlugBuilder, which will be used in a subsequent commit.
1 parent ba091f6 commit 5a069b0

3 files changed

Lines changed: 29 additions & 6 deletions

File tree

pkg/gitreceive/build.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ func build(conf *Config, s3Client *storage.Client, kubeClient *client.Client, fs
223223
conf.ObjectStorageTickDuration(),
224224
conf.ObjectStorageWaitDuration(),
225225
conf.Bucket,
226-
slugBuilderInfo.PushKey(),
226+
slugBuilderInfo.AbsoluteSlugObjectKey(),
227227
)
228228
// poll the s3 server to ensure the slug exists
229229
if err := storage.WaitForObject(
230230
s3Client,
231231
conf.Bucket,
232-
slugBuilderInfo.PushKey(),
232+
slugBuilderInfo.AbsoluteSlugObjectKey(),
233233
conf.ObjectStorageTickDuration(),
234234
conf.ObjectStorageWaitDuration(),
235235
); err != nil {

pkg/gitreceive/storage/slug_builder_info.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import (
66
"github.com/deis/builder/pkg/gitreceive/git"
77
)
88

9+
const (
10+
slugTGZName = "slug.tgz"
11+
)
12+
913
// SlugBuilderInfo contains all of the object storage related information needed to pass to a slug builder
1014
type SlugBuilderInfo struct {
1115
pushKey string
@@ -28,7 +32,11 @@ func NewSlugBuilderInfo(s3Endpoint *Endpoint, bucket, appName, slugName string,
2832
}
2933
}
3034

31-
func (s SlugBuilderInfo) PushKey() string { return s.pushKey }
32-
func (s SlugBuilderInfo) PushURL() string { return s.pushURL }
33-
func (s SlugBuilderInfo) TarKey() string { return s.tarKey }
34-
func (s SlugBuilderInfo) TarURL() string { return s.tarURL }
35+
func (s SlugBuilderInfo) PushKey() string { return s.pushKey }
36+
func (s SlugBuilderInfo) PushURL() string { return s.pushURL }
37+
func (s SlugBuilderInfo) TarKey() string { return s.tarKey }
38+
func (s SlugBuilderInfo) TarURL() string { return s.tarURL }
39+
func (s SlugBuilderInfo) AbsoluteSlugObjectKey() string { return s.PushKey() + "/" + slugTGZName }
40+
func (s SlugBuilderInfo) AbsoluteSlugURL() string {
41+
return s.PushURL() + "/" + s.AbsoluteSlugObjectKey()
42+
}

pkg/gitreceive/storage/slug_builder_info_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package storage
33
import (
44
"testing"
55

6+
"github.com/arschles/assert"
67
"github.com/deis/builder/pkg/gitreceive/git"
78
)
89

@@ -57,3 +58,17 @@ func TestTarKey(t *testing.T) {
5758
t.Errorf("tar key %s didn't match expected %s", sbi.TarKey(), expectedTarKey)
5859
}
5960
}
61+
62+
func TestAbsoluteSlugObjectKey(t *testing.T) {
63+
sha, err := git.NewSha(rawSha)
64+
assert.NoErr(t, err)
65+
sbi := NewSlugBuilderInfo(s3Endpoint, bucket, appName, slugName, sha)
66+
assert.Equal(t, sbi.AbsoluteSlugObjectKey(), sbi.PushKey()+"/"+slugTGZName, "absolute slug key")
67+
}
68+
69+
func TestAbsoluteSlugURL(t *testing.T) {
70+
sha, err := git.NewSha(rawSha)
71+
assert.NoErr(t, err)
72+
sbi := NewSlugBuilderInfo(s3Endpoint, bucket, appName, slugName, sha)
73+
assert.Equal(t, sbi.AbsoluteSlugURL(), sbi.PushURL()+"/"+sbi.PushKey()+"/"+slugTGZName, "absolute slug URL")
74+
}

0 commit comments

Comments
 (0)