MarshalJSON converts a Deployment into a Cloud Controller Deployment.
()
| 49 | |
| 50 | // MarshalJSON converts a Deployment into a Cloud Controller Deployment. |
| 51 | func (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 | |
| 88 | type CanaryStepStatus struct { |
| 89 | CurrentStep int `json:"current"` |