-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuilds.go
More file actions
54 lines (39 loc) · 1.11 KB
/
builds.go
File metadata and controls
54 lines (39 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package builds
import (
"encoding/json"
"fmt"
"github.com/deis/deis/client/controller/api"
"github.com/deis/deis/client/controller/client"
)
// List lists an app's builds.
func List(c *client.Client, appID string, results int) ([]api.Build, int, error) {
u := fmt.Sprintf("/v1/apps/%s/builds/", appID)
body, count, err := c.LimitedRequest(u, results)
if err != nil {
return []api.Build{}, -1, err
}
var builds []api.Build
if err = json.Unmarshal([]byte(body), &builds); err != nil {
return []api.Build{}, -1, err
}
return builds, count, nil
}
// New creates a build for an app.
func New(c *client.Client, appID string, image string,
procfile map[string]string) (api.Build, error) {
u := fmt.Sprintf("/v1/apps/%s/builds/", appID)
req := api.CreateBuildRequest{Image: image, Procfile: procfile}
body, err := json.Marshal(req)
if err != nil {
return api.Build{}, err
}
resBody, err := c.BasicRequest("POST", u, body)
if err != nil {
return api.Build{}, err
}
build := api.Build{}
if err = json.Unmarshal([]byte(resBody), &build); err != nil {
return api.Build{}, err
}
return build, nil
}