Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions resources/droplet_resource.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package resources

import (
"encoding/json"
"encoding/json"

"code.cloudfoundry.org/cli/v8/api/cloudcontroller"
"code.cloudfoundry.org/cli/v8/api/cloudcontroller"
"code.cloudfoundry.org/cli/v8/api/cloudcontroller/ccv3/constant"
)

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

// An object describing the lifecycle that was used when staging the droplet
// possible values for type: "buildpack", "cnb", "docker"
type DropletLifecycle struct {
Type string `json:"type"`
}

func (d Droplet) MarshallJSON() ([]byte, error) {
type ccDroplet struct {
GUID string `json:"guid,omitempty"`
Buildpacks []DropletBuildpack `json:"buildpacks,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
Lifecycle DropletLifecycle `json:"lifecycle,omitempty"`
Image string `json:"image,omitempty"`
Stack string `json:"stack,omitempty"`
State constant.DropletState `json:"state,omitempty"`
Expand All @@ -62,6 +71,7 @@ func (d Droplet) MarshallJSON() ([]byte, error) {
GUID: d.GUID,
Buildpacks: d.Buildpacks,
CreatedAt: d.CreatedAt,
Lifecycle: d.Lifecycle,
Image: d.Image,
Stack: d.Stack,
State: d.State,
Expand Down Expand Up @@ -98,6 +108,7 @@ func (d *Droplet) UnmarshalJSON(data []byte) error {
Buildpacks []DropletBuildpack `json:"buildpacks,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
Image string `json:"image,omitempty"`
Lifecycle DropletLifecycle `json:"lifecycle,omitempty"`
Stack string `json:"stack,omitempty"`
State constant.DropletState `json:"state,omitempty"`
Relationships struct {
Expand All @@ -118,6 +129,7 @@ func (d *Droplet) UnmarshalJSON(data []byte) error {
d.Buildpacks = alias.Buildpacks
d.CreatedAt = alias.CreatedAt
d.Image = alias.Image
d.Lifecycle = alias.Lifecycle
d.Stack = alias.Stack
d.State = alias.State
d.AppGUID = alias.Relationships.App.Data.GUID
Expand Down
Loading