Merge pull request #29152 from aaronlehmann/cluster-object-1.12.x

[1.12.x] cluster: Refuse swarm spec not named "default"
This commit is contained in:
Victor Vieux 2016-12-05 16:36:42 -08:00 committed by GitHub
commit cce6065906

View file

@ -2,6 +2,7 @@ package cluster
import (
"encoding/json"
stdliberrors "errors"
"fmt"
"io/ioutil"
"net"
@ -1322,6 +1323,8 @@ func validateAndSanitizeInitRequest(req *types.InitRequest) error {
// provide sane defaults instead of erroring
if spec.Name == "" {
spec.Name = "default"
} else if spec.Name != "default" {
return stdliberrors.New(`swarm spec must be named "default"`)
}
if spec.Raft.SnapshotInterval == 0 {
spec.Raft.SnapshotInterval = defaultSpec.Raft.SnapshotInterval