Skip to content

Commit 2ead768

Browse files
Make droplet's lifecycle information available (#3634)
* Make droplet's lifecycle information available * Fix Type; Adjust json tag
1 parent cc4495a commit 2ead768

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

resources/droplet_resource.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package resources
22

33
import (
4-
"encoding/json"
4+
"encoding/json"
55

6-
"code.cloudfoundry.org/cli/v8/api/cloudcontroller"
6+
"code.cloudfoundry.org/cli/v8/api/cloudcontroller"
77
"code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant"
88
)
99

@@ -18,6 +18,8 @@ type Droplet struct {
1818
CreatedAt string `json:"created_at"`
1919
// GUID is the unique droplet identifier.
2020
GUID string `json:"guid"`
21+
// An object describing the lifecycle that was used when staging the droplet
22+
Lifecycle DropletLifecycle `json:"lifecycle"`
2123
// Image is the Docker image name.
2224
Image string `json:"image"`
2325
// Stack is the root filesystem to use with the buildpack.
@@ -41,11 +43,18 @@ type DropletBuildpack struct {
4143
Version string `json:"version"`
4244
}
4345

46+
// An object describing the lifecycle that was used when staging the droplet
47+
// possible values for type: "buildpack", "cnb", "docker"
48+
type DropletLifecycle struct {
49+
Type string `json:"type"`
50+
}
51+
4452
func (d Droplet) MarshallJSON() ([]byte, error) {
4553
type ccDroplet struct {
4654
GUID string `json:"guid,omitempty"`
4755
Buildpacks []DropletBuildpack `json:"buildpacks,omitempty"`
4856
CreatedAt string `json:"created_at,omitempty"`
57+
Lifecycle DropletLifecycle `json:"lifecycle,omitempty"`
4958
Image string `json:"image,omitempty"`
5059
Stack string `json:"stack,omitempty"`
5160
State constant.DropletState `json:"state,omitempty"`
@@ -62,6 +71,7 @@ func (d Droplet) MarshallJSON() ([]byte, error) {
6271
GUID: d.GUID,
6372
Buildpacks: d.Buildpacks,
6473
CreatedAt: d.CreatedAt,
74+
Lifecycle: d.Lifecycle,
6575
Image: d.Image,
6676
Stack: d.Stack,
6777
State: d.State,
@@ -98,6 +108,7 @@ func (d *Droplet) UnmarshalJSON(data []byte) error {
98108
Buildpacks []DropletBuildpack `json:"buildpacks,omitempty"`
99109
CreatedAt string `json:"created_at,omitempty"`
100110
Image string `json:"image,omitempty"`
111+
Lifecycle DropletLifecycle `json:"lifecycle,omitempty"`
101112
Stack string `json:"stack,omitempty"`
102113
State constant.DropletState `json:"state,omitempty"`
103114
Relationships struct {
@@ -118,6 +129,7 @@ func (d *Droplet) UnmarshalJSON(data []byte) error {
118129
d.Buildpacks = alias.Buildpacks
119130
d.CreatedAt = alias.CreatedAt
120131
d.Image = alias.Image
132+
d.Lifecycle = alias.Lifecycle
121133
d.Stack = alias.Stack
122134
d.State = alias.State
123135
d.AppGUID = alias.Relationships.App.Data.GUID

0 commit comments

Comments
 (0)