@@ -9,55 +9,31 @@ import (
99 "github.com/drycc/controller-sdk-go/api"
1010)
1111
12- // List lists an app's builds.
13- func List (c * drycc.Client , appID string , results int ) ([]api.Build , int , error ) {
14- u := fmt .Sprintf ("/v2/apps/%s/builds/" , appID )
15- body , count , reqErr := c .LimitedRequest (u , results )
12+ // Get a build of an app.
13+ func Get (c * drycc.Client , appID string , version int ) (api.Build , error ) {
14+ u := fmt .Sprintf ("/v2/apps/%s/build/" , appID )
15+ if version > 0 {
16+ u = fmt .Sprintf ("%s?version=v%d" , u , version )
17+ }
1618
19+ res , reqErr := c .Request ("GET" , u , nil )
1720 if reqErr != nil && ! drycc .IsErrAPIMismatch (reqErr ) {
18- return [] api.Build {}, - 1 , reqErr
21+ return api.Build {}, reqErr
1922 }
23+ defer res .Body .Close ()
2024
21- var builds [] api.Build
22- if err := json .Unmarshal ([] byte ( body ), & builds ); err != nil {
23- return [] api.Build {}, - 1 , err
25+ var build api.Build
26+ if err := json .NewDecoder ( res . Body ). Decode ( & build ); err != nil {
27+ return api.Build {}, err
2428 }
25-
26- return builds , count , reqErr
29+ return build , reqErr
2730}
2831
29- // New creates a build for an app from an container image.
30- // By default this will create a cmd process that runs the CMD command from the Dockerfile.
31- // If you want to define more process types, you can pass a Procfile map,
32- // where the key is the process name and the value is the command for that process.
33- // To pull from a private container registry, a custom username and password must be set in the app's
34- // configuration object. This can be done with `drycc registry:set` or by using this SDK.
35- //
36- // This example adds custom registry credentials to an app:
37- //
38- // import (
39- // "github.com/drycc/controller-sdk-go/api"
40- // "github.com/drycc/controller-sdk-go/config"
41- // )
42- //
43- // // Create username/password map
44- // registryMap := map[string]string{
45- // "username": "password"
46- // }
47- //
48- // // Create a new configuration, assign the credentials, and set it.
49- // // Note that config setting is a patching operation, it doesn't overwrite or unset
50- // // unrelated configuration.
51- // newConfig := api.Config{}
52- // newConfig.Registry = registryMap
53- // _, err := config.Set(<client>, "appname", newConfig)
54- // if err != nil {
55- // log.Fatal(err)
56- // }
32+ // New a build of an app.
5733func New (c * drycc.Client , appID string , image string , stack string ,
5834 procfile map [string ]string , dryccfile map [string ]interface {}) (api.Build , error ) {
5935
60- u := fmt .Sprintf ("/v2/apps/%s/builds /" , appID )
36+ u := fmt .Sprintf ("/v2/apps/%s/build /" , appID )
6137
6238 req := api.CreateBuildRequest {
6339 Image : image ,
0 commit comments