Skip to content

Commit 071c7d4

Browse files
cihangirbesiktasLuis Davim
authored andcommitted
residency field support is added
1 parent 6522008 commit 071c7d4

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

application.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type Application struct {
6969
Executor *string `json:"executor,omitempty"`
7070
HealthChecks *[]HealthCheck `json:"healthChecks,omitempty"`
7171
ReadinessChecks *[]ReadinessCheck `json:"readinessChecks,omitempty"`
72+
Residency *Residency `json:"residency,omitempty"`
7273
Instances *int `json:"instances,omitempty"`
7374
Mem *float64 `json:"mem,omitempty"`
7475
Tasks []*Task `json:"tasks,omitempty"`
@@ -462,6 +463,20 @@ func (r *Application) EmptyReadinessChecks() *Application {
462463
return r
463464
}
464465

466+
// SetResidency sets the upgrade strategy.
467+
func (r *Application) SetResidency(us Residency) *Application {
468+
r.Residency = &us
469+
return r
470+
}
471+
472+
// EmptyResidency explicitly empties the residency -- use this if
473+
// you need to empty the residency of an application that already has
474+
// the residency set (setting it to nil will keep the current value).
475+
func (r *Application) EmptyResidency() *Application {
476+
r.Residency = &Residency{}
477+
return r
478+
}
479+
465480
// DeploymentIDs retrieves the application deployments IDs
466481
func (r *Application) DeploymentIDs() []*DeploymentID {
467482
var deployments []*DeploymentID

residency.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright 2014 Rohith All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package marathon
18+
19+
// Residency is the definition for an application residency
20+
type Residency struct {
21+
RelaunchEscalationTimeoutSeconds *int `json:"relaunchEscalationTimeoutSeconds,omitempty"`
22+
TaskLostBehavior *string `json:"taskLostBehavior,omitempty"`
23+
}
24+
25+
// SetRelaunchEscalationTimeoutSeconds sets the given relaunch escalation timeout on the residency.
26+
func (r Residency) SetRelaunchEscalationTimeoutSeconds(i int) Residency {
27+
r.RelaunchEscalationTimeoutSeconds = &i
28+
return r
29+
}
30+
31+
// SetRelaunchEscalationTimeoutSeconds sets the given relaunch escalation timeout on the residency.
32+
func (r Residency) SetTaskLostBehavior(s string) Residency {
33+
r.TaskLostBehavior = &s
34+
return r
35+
}

residency_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package marathon
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestResidencyCheck(t *testing.T) {
10+
rc := Residency{}
11+
rc.SetRelaunchEscalationTimeoutSeconds(3600).
12+
SetTaskLostBehavior("WAIT_FOREVER")
13+
14+
assert.Equal(t, rc.RelaunchEscalationTimeoutSeconds, 3600)
15+
assert.Equal(t, rc.TaskLostBehavior, "WAIT_FOREVER")
16+
}

0 commit comments

Comments
 (0)