Skip to content

Commit 10676f2

Browse files
committed
feat(pipeline): add dryccfile support
1 parent b558c52 commit 10676f2

7 files changed

Lines changed: 60 additions & 44 deletions

File tree

api/builds.go

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,35 @@ package api
22

33
// Build is the structure of the build object.
44
type Build struct {
5-
App string `json:"app"`
6-
Created string `json:"created"`
7-
Dockerfile string `json:"dockerfile,omitempty"`
8-
Image string `json:"image,omitempty"`
9-
Stack string `json:"stack,omitempty"`
10-
Owner string `json:"owner"`
11-
Procfile map[string]string `json:"procfile"`
12-
Sha string `json:"sha,omitempty"`
13-
Updated string `json:"updated"`
14-
UUID string `json:"uuid"`
5+
App string `json:"app"`
6+
Created string `json:"created"`
7+
Dockerfile string `json:"dockerfile,omitempty"`
8+
Image string `json:"image,omitempty"`
9+
Stack string `json:"stack,omitempty"`
10+
Owner string `json:"owner"`
11+
Procfile map[string]string `json:"procfile"`
12+
Dryccfile map[string]interface{} `json:"dryccfile"`
13+
Sha string `json:"sha,omitempty"`
14+
Updated string `json:"updated"`
15+
UUID string `json:"uuid"`
1516
}
1617

1718
// CreateBuildRequest is the structure of POST /v2/apps/<app id>/builds/.
1819
type CreateBuildRequest struct {
19-
Image string `json:"image"`
20-
Stack string `json:"stack,omitempty"`
21-
Procfile map[string]string `json:"procfile,omitempty"`
20+
Image string `json:"image"`
21+
Stack string `json:"stack,omitempty"`
22+
Procfile map[string]string `json:"procfile,omitempty"`
23+
Dryccfile map[string]interface{} `json:"dryccfile,omitempty"`
2224
}
2325

2426
// BuildHookRequest is a hook request to create a new build.
2527
type BuildHookRequest struct {
26-
Sha string `json:"sha"`
27-
User string `json:"receive_user"`
28-
App string `json:"receive_repo"`
29-
Image string `json:"image"`
30-
Stack string `json:"stack"`
31-
Procfile ProcessType `json:"procfile"`
32-
Dockerfile string `json:"dockerfile"`
28+
Sha string `json:"sha"`
29+
User string `json:"receive_user"`
30+
App string `json:"receive_repo"`
31+
Image string `json:"image"`
32+
Stack string `json:"stack"`
33+
Procfile ProcessType `json:"procfile"`
34+
Dockerfile string `json:"dockerfile"`
35+
Dryccfile map[string]interface{} `json:"dryccfile"`
3336
}

api/releases.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package api
33
// Release is the definition of the release object.
44
type Release struct {
55
App string `json:"app"`
6+
State string `json:"state"`
67
Build string `json:"build,omitempty"`
78
Config string `json:"config"`
89
Created string `json:"created"`

builds/builds.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,17 @@ func List(c *drycc.Client, appID string, results int) ([]api.Build, int, error)
5454
// if err != nil {
5555
// log.Fatal(err)
5656
// }
57-
func New(c *drycc.Client, appID string, image string,
58-
stack string, procfile map[string]string) (api.Build, error) {
57+
func New(c *drycc.Client, appID string, image string, stack string,
58+
procfile map[string]string, dryccfile map[string]interface{}) (api.Build, error) {
5959

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

62-
req := api.CreateBuildRequest{Image: image, Stack: stack, Procfile: procfile}
62+
req := api.CreateBuildRequest{
63+
Image: image,
64+
Stack: stack,
65+
Procfile: procfile,
66+
Dryccfile: dryccfile,
67+
}
6368

6469
body, err := json.Marshal(req)
6570

builds/builds_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const buildsFixture string = `
2828
"procfile": {
2929
"web": "example-go"
3030
},
31+
"dryccfile": {},
3132
"sha": "060da68f",
3233
"updated": "2014-01-01T00:00:00UTC",
3334
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
@@ -46,6 +47,7 @@ const buildFixture string = `
4647
"procfile": {
4748
"web": "example-go"
4849
},
50+
"dryccfile": {},
4951
"sha": "",
5052
"updated": "2014-01-01T00:00:00UTC",
5153
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
@@ -100,12 +102,11 @@ func TestBuildsList(t *testing.T) {
100102
Image: "example-go",
101103
Stack: "container",
102104
Owner: "test",
103-
Procfile: map[string]string{
104-
"web": "example-go",
105-
},
106-
Sha: "060da68f",
107-
Updated: "2014-01-01T00:00:00UTC",
108-
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
105+
Procfile: map[string]string{"web": "example-go"},
106+
Dryccfile: map[string]interface{}{},
107+
Sha: "060da68f",
108+
Updated: "2014-01-01T00:00:00UTC",
109+
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
109110
},
110111
}
111112

@@ -133,16 +134,15 @@ func TestBuildCreate(t *testing.T) {
133134
t.Parallel()
134135

135136
expected := api.Build{
136-
App: "example-go",
137-
Created: "2014-01-01T00:00:00UTC",
138-
Image: "drycc/example-go:latest",
139-
Stack: "heroku-18",
140-
Owner: "test",
141-
Procfile: map[string]string{
142-
"web": "example-go",
143-
},
144-
Updated: "2014-01-01T00:00:00UTC",
145-
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
137+
App: "example-go",
138+
Created: "2014-01-01T00:00:00UTC",
139+
Image: "drycc/example-go:latest",
140+
Stack: "heroku-18",
141+
Owner: "test",
142+
Procfile: map[string]string{"web": "example-go"},
143+
Dryccfile: map[string]interface{}{},
144+
Updated: "2014-01-01T00:00:00UTC",
145+
UUID: "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
146146
}
147147

148148
handler := fakeHTTPServer{}
@@ -158,7 +158,7 @@ func TestBuildCreate(t *testing.T) {
158158
"web": "example-go",
159159
}
160160

161-
actual, err := New(drycc, "example-go", "drycc/example-go", "heroku-18", procfile)
161+
actual, err := New(drycc, "example-go", "drycc/example-go", "heroku-18", procfile, map[string]interface{}{})
162162

163163
if err != nil {
164164
t.Fatal(err)

hooks/hooks.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ 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 container 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, stack, gitSha string, procfile api.ProcessType,
57-
dockerfile string) (int, error) {
56+
func CreateBuild(c *drycc.Client, username, app, image, stack, gitSha string,
57+
procfile api.ProcessType, dryccfile map[string]interface{}, dockerfile string) (int, error) {
5858
req := api.BuildHookRequest{
5959
Sha: gitSha,
6060
User: username,
@@ -63,6 +63,7 @@ func CreateBuild(c *drycc.Client, username, app, image, stack, gitSha string, pr
6363
Stack: stack,
6464
Procfile: procfile,
6565
Dockerfile: dockerfile,
66+
Dryccfile: dryccfile,
6667
}
6768

6869
b, err := json.Marshal(req)

hooks/hooks_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const buildFixture = `
5252
const (
5353
testingClientFingerprint = `78:b9:21:20:1a:ed:e6:10:05:35:47:da:d4:1f:b6:73`
5454
configHookExpected = `{"receive_user":"test","receive_repo":"example-go"}`
55-
buildHookExpected = `{"sha":"abc123","receive_user":"test","receive_repo":"example-go","image":"test:abc123","stack":"heroku-18","procfile":{"web":"./run"},"dockerfile":""}`
55+
buildHookExpected = `{"sha":"abc123","receive_user":"test","receive_repo":"example-go","image":"test:abc123","stack":"heroku-18","procfile":{"web":"./run"},"dockerfile":"","dryccfile":{}}`
5656
)
5757

5858
type fakeHTTPServer struct{}
@@ -198,7 +198,9 @@ func TestBuildHook(t *testing.T) {
198198

199199
expected := 2
200200

201-
actual, err := CreateBuild(drycc, "test", "example-go", "test:abc123", "heroku-18", "abc123", map[string]string{"web": "./run"}, "")
201+
actual, err := CreateBuild(
202+
drycc, "test", "example-go", "test:abc123", "heroku-18", "abc123",
203+
map[string]string{"web": "./run"}, map[string]interface{}{}, "")
202204

203205
if err != nil {
204206
t.Error(err)

releases/releases_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const releasesFixture string = `
2020
"results": [
2121
{
2222
"app": "example-go",
23+
"state": "succeed",
2324
"build": null,
2425
"config": "95bd6dea-1685-4f78-a03d-fd7270b058d1",
2526
"created": "2014-01-01T00:00:00UTC",
@@ -36,6 +37,7 @@ const releaseFixture string = `
3637
{
3738
"app": "example-go",
3839
"build": null,
40+
"state": "succeed",
3941
"config": "95bd6dea-1685-4f78-a03d-fd7270b058d1",
4042
"created": "2014-01-01T00:00:00UTC",
4143
"owner": "test",
@@ -125,6 +127,7 @@ func TestReleasesList(t *testing.T) {
125127
{
126128
App: "example-go",
127129
Build: "",
130+
State: "succeed",
128131
Config: "95bd6dea-1685-4f78-a03d-fd7270b058d1",
129132
Created: "2014-01-01T00:00:00UTC",
130133
Owner: "test",
@@ -160,6 +163,7 @@ func TestReleasesGet(t *testing.T) {
160163

161164
expected := api.Release{
162165
App: "example-go",
166+
State: "succeed",
163167
Build: "",
164168
Config: "95bd6dea-1685-4f78-a03d-fd7270b058d1",
165169
Created: "2014-01-01T00:00:00UTC",

0 commit comments

Comments
 (0)