Skip to content

Commit dc4b852

Browse files
Make droplet's lifecycle information available (#3633)
* Make droplet's lifecycle information available * Fix Type; Adjust json tag --------- Co-authored-by: Shwetha Gururaj <shwetha.gururaj@broadcom.com>
1 parent 94f0f38 commit dc4b852

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

resources/droplet_resource.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package resources
22

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

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

1010
// Droplet represents a Cloud Controller droplet's metadata. A droplet is a set of
@@ -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,12 +43,19 @@ 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"`
4957
Image string `json:"image,omitempty"`
58+
Lifecycle DropletLifecycle `json:"lifecycle,omitempty"`
5059
Stack string `json:"stack,omitempty"`
5160
State constant.DropletState `json:"state,omitempty"`
5261
Relationships *struct {
@@ -63,6 +72,7 @@ func (d Droplet) MarshallJSON() ([]byte, error) {
6372
Buildpacks: d.Buildpacks,
6473
CreatedAt: d.CreatedAt,
6574
Image: d.Image,
75+
Lifecycle: d.Lifecycle,
6676
Stack: d.Stack,
6777
State: d.State,
6878
}
@@ -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)