Skip to content

Commit 39a6c81

Browse files
committed
feat(stack): add stack support
1 parent 60d01c3 commit 39a6c81

5 files changed

Lines changed: 15 additions & 7 deletions

File tree

api/builds.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ type Build struct {
66
Created string `json:"created"`
77
Dockerfile string `json:"dockerfile,omitempty"`
88
Image string `json:"image,omitempty"`
9+
Stack string `json:"stack,omitempty"`
910
Owner string `json:"owner"`
1011
Procfile map[string]string `json:"procfile"`
1112
Sha string `json:"sha,omitempty"`
@@ -16,6 +17,7 @@ type Build struct {
1617
// CreateBuildRequest is the structure of POST /v2/apps/<app id>/builds/.
1718
type CreateBuildRequest struct {
1819
Image string `json:"image"`
20+
Stack string `json:"stack,omitempty"`
1921
Procfile map[string]string `json:"procfile,omitempty"`
2022
}
2123

@@ -25,6 +27,7 @@ type BuildHookRequest struct {
2527
User string `json:"receive_user"`
2628
App string `json:"receive_repo"`
2729
Image string `json:"image"`
30+
Stack string `json:"stack"`
2831
Procfile ProcessType `json:"procfile"`
2932
Dockerfile string `json:"dockerfile"`
3033
}

builds/builds.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ func List(c *drycc.Client, appID string, results int) ([]api.Build, int, error)
5454
// log.Fatal(err)
5555
// }
5656
func New(c *drycc.Client, appID string, image string,
57-
procfile map[string]string) (api.Build, error) {
57+
stack string, procfile map[string]string) (api.Build, error) {
5858

5959
u := fmt.Sprintf("/v2/apps/%s/builds/", appID)
6060

61-
req := api.CreateBuildRequest{Image: image, Procfile: procfile}
61+
req := api.CreateBuildRequest{Image: image, Stack: stack, Procfile: procfile}
6262

6363
body, err := json.Marshal(req)
6464

builds/builds_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const buildsFixture string = `
2323
"created": "2014-01-01T00:00:00UTC",
2424
"dockerfile": "FROM drycc/slugrunner RUN mkdir -p /app WORKDIR /app ENTRYPOINT [\"/runner/init\"] ADD slug.tgz /app ENV GIT_SHA 060da68f654e75fac06dbedd1995d5f8ad9084db",
2525
"image": "example-go",
26+
"stack": "container",
2627
"owner": "test",
2728
"procfile": {
2829
"web": "example-go"
@@ -40,6 +41,7 @@ const buildFixture string = `
4041
"created": "2014-01-01T00:00:00UTC",
4142
"dockerfile": "",
4243
"image": "drycc/example-go:latest",
44+
"stack": "heroku-18",
4345
"owner": "test",
4446
"procfile": {
4547
"web": "example-go"
@@ -49,7 +51,7 @@ const buildFixture string = `
4951
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
5052
}`
5153

52-
const buildExpected string = `{"image":"drycc/example-go","procfile":{"web":"example-go"}}`
54+
const buildExpected string = `{"image":"drycc/example-go","stack":"heroku-18","procfile":{"web":"example-go"}}`
5355

5456
type fakeHTTPServer struct{}
5557

@@ -96,6 +98,7 @@ func TestBuildsList(t *testing.T) {
9698
Created: "2014-01-01T00:00:00UTC",
9799
Dockerfile: "FROM drycc/slugrunner RUN mkdir -p /app WORKDIR /app ENTRYPOINT [\"/runner/init\"] ADD slug.tgz /app ENV GIT_SHA 060da68f654e75fac06dbedd1995d5f8ad9084db",
98100
Image: "example-go",
101+
Stack: "container",
99102
Owner: "test",
100103
Procfile: map[string]string{
101104
"web": "example-go",
@@ -133,6 +136,7 @@ func TestBuildCreate(t *testing.T) {
133136
App: "example-go",
134137
Created: "2014-01-01T00:00:00UTC",
135138
Image: "drycc/example-go:latest",
139+
Stack: "heroku-18",
136140
Owner: "test",
137141
Procfile: map[string]string{
138142
"web": "example-go",
@@ -154,7 +158,7 @@ func TestBuildCreate(t *testing.T) {
154158
"web": "example-go",
155159
}
156160

157-
actual, err := New(drycc, "example-go", "drycc/example-go", procfile)
161+
actual, err := New(drycc, "example-go", "drycc/example-go", "heroku-18", procfile)
158162

159163
if err != nil {
160164
t.Fatal(err)

hooks/hooks.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ func GetAppConfig(c *drycc.Client, username, app string) (api.Config, error) {
5353
// CreateBuild creates a new release of an application. It returns the version of the new release.
5454
// gitSha should be the first 8 characters of the git commit sha. Image is either the docker image
5555
// location for the dockerfile app the absolute url to the tar file for a buldpack app.
56-
func CreateBuild(c *drycc.Client, username, app, image, gitSha string, procfile api.ProcessType,
56+
func CreateBuild(c *drycc.Client, username, app, image, stack, gitSha string, procfile api.ProcessType,
5757
usingDockerifle bool) (int, error) {
5858
req := api.BuildHookRequest{
5959
Sha: gitSha,
6060
User: username,
6161
App: app,
6262
Image: image,
63+
Stack: stack,
6364
Procfile: procfile,
6465
}
6566

hooks/hooks_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const buildFixture = `
5555
const (
5656
testingClientFingerprint = `78:b9:21:20:1a:ed:e6:10:05:35:47:da:d4:1f:b6:73`
5757
configHookExpected = `{"receive_user":"test","receive_repo":"example-go"}`
58-
buildHookExpected = `{"sha":"abc123","receive_user":"test","receive_repo":"example-go","image":"test:abc123","procfile":{"web":"./run"},"dockerfile":"true"}`
58+
buildHookExpected = `{"sha":"abc123","receive_user":"test","receive_repo":"example-go","image":"test:abc123","stack":"heroku-18","procfile":{"web":"./run"},"dockerfile":"true"}`
5959
pushHookExpected = `{"sha":"abc123","receive_user":"test","receive_repo":"example-go","fingerprint":"testing","ssh_connection":"1234","ssh_original_command":"foo"}`
6060
)
6161

@@ -205,7 +205,7 @@ func TestBuildHook(t *testing.T) {
205205

206206
expected := 2
207207

208-
actual, err := CreateBuild(drycc, "test", "example-go", "test:abc123", "abc123", map[string]string{"web": "./run"}, true)
208+
actual, err := CreateBuild(drycc, "test", "example-go", "test:abc123", "heroku-18", "abc123", map[string]string{"web": "./run"}, true)
209209

210210
if err != nil {
211211
t.Error(err)

0 commit comments

Comments
 (0)