Skip to content

Commit e10661b

Browse files
authored
Fix null canary object (#3435)
* Do not send null canary object if no steps have been specified
1 parent 2ad2691 commit e10661b

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

actor/v7pushaction/create_deployment_for_push_plan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func (actor Actor) CreateDeploymentForApplication(pushPlan PushPlan, eventStream
1919
}
2020

2121
if len(pushPlan.InstanceSteps) > 0 {
22-
dep.Options.CanaryDeploymentOptions = resources.CanaryDeploymentOptions{Steps: []resources.CanaryStep{}}
22+
dep.Options.CanaryDeploymentOptions = &resources.CanaryDeploymentOptions{Steps: []resources.CanaryStep{}}
2323
for _, w := range pushPlan.InstanceSteps {
2424
dep.Options.CanaryDeploymentOptions.Steps = append(dep.Options.CanaryDeploymentOptions.Steps, resources.CanaryStep{InstanceWeight: w})
2525
}

actor/v7pushaction/create_deployment_for_push_plan_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ var _ = Describe("CreateDeploymentForApplication()", func() {
175175
Expect(dep).To(Equal(resources.Deployment{
176176
Strategy: "canary",
177177
Options: resources.DeploymentOpts{
178-
CanaryDeploymentOptions: resources.CanaryDeploymentOptions{
178+
CanaryDeploymentOptions: &resources.CanaryDeploymentOptions{
179179
Steps: []resources.CanaryStep{
180180
{InstanceWeight: 1},
181181
{InstanceWeight: 2},

api/cloudcontroller/ccv3/deployment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ var _ = Describe("Deployment", func() {
251251
dep.Strategy = constant.DeploymentStrategyCanary
252252
dep.RevisionGUID = revisionGUID
253253
dep.Relationships = resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: "some-app-guid"}}
254-
dep.Options.CanaryDeploymentOptions = resources.CanaryDeploymentOptions{Steps: []resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}}}
254+
dep.Options.CanaryDeploymentOptions = &resources.CanaryDeploymentOptions{Steps: []resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}}}
255255
deploymentGUID, warnings, executeErr = client.CreateApplicationDeployment(dep)
256256
})
257257

resources/deployment_resource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ type Deployment struct {
2424
}
2525

2626
type DeploymentOpts struct {
27-
MaxInFlight int `json:"max_in_flight,omitempty"`
28-
CanaryDeploymentOptions CanaryDeploymentOptions `json:"canary,omitempty"`
27+
MaxInFlight int `json:"max_in_flight,omitempty"`
28+
CanaryDeploymentOptions *CanaryDeploymentOptions `json:"canary,omitempty"`
2929
}
3030

3131
func (d DeploymentOpts) IsEmpty() bool {
32-
return d.MaxInFlight == 0 && len(d.CanaryDeploymentOptions.Steps) == 0
32+
return d.MaxInFlight == 0 && (d.CanaryDeploymentOptions == nil || len(d.CanaryDeploymentOptions.Steps) == 0)
3333
}
3434

3535
type CanaryDeploymentOptions struct {

0 commit comments

Comments
 (0)