Skip to content

Commit 48b0503

Browse files
authored
Merge pull request #459 from cloudfoundry/build-update-image
Build update image
2 parents 59621eb + 7328fc9 commit 48b0503

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

client/build_test.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestBuilds(t *testing.T) {
5757
},
5858
},
5959
{
60-
Description: "Update build",
60+
Description: "Update build metadata",
6161
Route: testutil.MockRoute{
6262
Method: "PATCH",
6363
Endpoint: "/v3/builds/be9db090-ad79-41c1-9a01-6200d896f20f",
@@ -74,6 +74,27 @@ func TestBuilds(t *testing.T) {
7474
return c.Builds.Update(context.Background(), "be9db090-ad79-41c1-9a01-6200d896f20f", r)
7575
},
7676
},
77+
{
78+
Description: "Update build image",
79+
Route: testutil.MockRoute{
80+
Method: "PATCH",
81+
Endpoint: "/v3/builds/be9db090-ad79-41c1-9a01-6200d896f20f",
82+
Output: g.Single(build),
83+
PostForm: `{"state": "STAGED", "lifecycle": {"data": {"image": "image-identifier"}}}`,
84+
Status: http.StatusOK,
85+
},
86+
Expected: build,
87+
Action: func(c *Client, t *testing.T) (any, error) {
88+
r := resource.NewBuildUpdate()
89+
r.State = "STAGED"
90+
r.Lifecycle = &resource.Lifecycle{
91+
BuildpackData: resource.BuildpackLifecycle{
92+
Image: "image-identifier",
93+
},
94+
}
95+
return c.Builds.Update(context.Background(), "be9db090-ad79-41c1-9a01-6200d896f20f", r)
96+
},
97+
},
7798
{
7899
Description: "List first page of builds",
79100
Route: testutil.MockRoute{

client/droplet_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func TestDroplets(t *testing.T) {
188188
Expected: droplet,
189189
Action: func(c *Client, t *testing.T) (any, error) {
190190
return c.Droplets.Update(context.Background(), "59c3d133-2b83-46f3-960e-7765a129aea4", &resource.DropletUpdate{
191-
Image: testutil.StringPtr("image-identifier"),
191+
Image: "image-identifier",
192192
})
193193
},
194194
},

resource/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type Lifecycle struct {
7070
type BuildpackLifecycle struct {
7171
Buildpacks []string `json:"buildpacks,omitempty"`
7272
Stack string `json:"stack,omitempty"`
73+
Image string `json:"image,omitempty"`
7374
}
7475

7576
type AppWithIncluded struct {

resource/build.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ type BuildCreate struct {
4040
}
4141

4242
type BuildUpdate struct {
43-
Metadata *Metadata `json:"metadata,omitempty"`
43+
Metadata *Metadata `json:"metadata,omitempty"`
44+
Lifecycle *Lifecycle `json:"lifecycle,omitempty"`
45+
State string `json:"state,omitempty"`
4446
}
4547

4648
type BuildList struct {

resource/droplet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type DropletList struct {
5151

5252
type DropletUpdate struct {
5353
Metadata *Metadata `json:"metadata,omitempty"`
54-
Image *string `json:"image,omitempty"`
54+
Image string `json:"image,omitempty"`
5555
}
5656

5757
type DropletCurrent struct {

0 commit comments

Comments
 (0)