MCPcopy Index your code
hub / github.com/cloudfoundry/cli / MarshalJSON

Method MarshalJSON

resources/deployment_resource.go:51–86  ·  view source on GitHub ↗

MarshalJSON converts a Deployment into a Cloud Controller Deployment.

()

Source from the content-addressed store, hash-verified

49
50// MarshalJSON converts a Deployment into a Cloud Controller Deployment.
51func (d Deployment) MarshalJSON() ([]byte, error) {
52 type Revision struct {
53 GUID string `json:"guid,omitempty"`
54 }
55 type Droplet struct {
56 GUID string `json:"guid,omitempty"`
57 }
58
59 var ccDeployment struct {
60 Droplet *Droplet `json:"droplet,omitempty"`
61 Options *DeploymentOpts `json:"options,omitempty"`
62 Revision *Revision `json:"revision,omitempty"`
63 Strategy constant.DeploymentStrategy `json:"strategy,omitempty"`
64 Relationships Relationships `json:"relationships,omitempty"`
65 }
66
67 if d.DropletGUID != "" {
68 ccDeployment.Droplet = &Droplet{d.DropletGUID}
69 }
70
71 if d.RevisionGUID != "" {
72 ccDeployment.Revision = &Revision{d.RevisionGUID}
73 }
74
75 if d.Strategy != "" {
76 ccDeployment.Strategy = d.Strategy
77 }
78
79 if !d.Options.IsEmpty() {
80 ccDeployment.Options = &d.Options
81 }
82
83 ccDeployment.Relationships = d.Relationships
84
85 return json.Marshal(ccDeployment)
86}
87
88type CanaryStepStatus struct {
89 CurrentStep int `json:"current"`

Callers

nothing calls this directly

Calls 1

IsEmptyMethod · 0.65

Tested by

no test coverage detected