Skip to content

Commit

Permalink
Support the "order" key in "update_config" for compose
Browse files Browse the repository at this point in the history
Signed-off-by: Antonis Kalipetis <akalipetis@gmail.com>
  • Loading branch information
akalipetis committed Jul 28, 2017
1 parent 286216d commit 2950667
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions cli/compose/convert/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ func convertUpdateConfig(source *composetypes.UpdateConfig) *swarm.UpdateConfig
FailureAction: source.FailureAction,
Monitor: source.Monitor,
MaxFailureRatio: source.MaxFailureRatio,
Order: source.Order,
}
}

Expand Down
18 changes: 18 additions & 0 deletions cli/compose/convert/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,21 @@ func TestConvertCredentialSpec(t *testing.T) {
assert.Error(t, err)
assert.Nil(t, swarmSpec)
}

func TestConvertUpdateConfigOrder(t *testing.T) {
// test default behavior
updateConfig := convertUpdateConfig(&composetypes.UpdateConfig{})
assert.Equal(t, "", updateConfig.Order)

// test start-first
updateConfig = convertUpdateConfig(&composetypes.UpdateConfig{
Order: "start-first",
})
assert.Equal(t, updateConfig.Order, "start-first")

// test stop-first
updateConfig = convertUpdateConfig(&composetypes.UpdateConfig{
Order: "stop-first",
})
assert.Equal(t, updateConfig.Order, "stop-first")
}
1 change: 1 addition & 0 deletions cli/compose/loader/full-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
failure_action: continue
monitor: 60s
max_failure_ratio: 0.3
order: start-first
resources:
limits:
cpus: '0.001'
Expand Down
1 change: 1 addition & 0 deletions cli/compose/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ func TestFullExample(t *testing.T) {
FailureAction: "continue",
Monitor: time.Duration(60 * time.Second),
MaxFailureRatio: 0.3,
Order: "start-first",
},
Resources: types.Resources{
Limits: &types.Resource{
Expand Down
2 changes: 1 addition & 1 deletion cli/compose/schema/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion cli/compose/schema/data/config_schema_v3.4.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,10 @@
"delay": {"type": "string", "format": "duration"},
"failure_action": {"type": "string"},
"monitor": {"type": "string", "format": "duration"},
"max_failure_ratio": {"type": "number"}
"max_failure_ratio": {"type": "number"},
"order": {"type": "string", "enum": [
"start-first", "stop-first"
]}
},
"additionalProperties": false
},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ type UpdateConfig struct {
FailureAction string `mapstructure:"failure_action"`
Monitor time.Duration
MaxFailureRatio float32 `mapstructure:"max_failure_ratio"`
Order string
}

// Resources the resource limits and reservations
Expand Down

0 comments on commit 2950667

Please sign in to comment.