Validate/sanitize swarmkit spec name.
Signed-off-by: Anshul Pundir <anshul.pundir@docker.com>
diff --git a/daemon/cluster/swarm.go b/daemon/cluster/swarm.go
index 6122369..ec527ce 100644
--- a/daemon/cluster/swarm.go
+++ b/daemon/cluster/swarm.go
@@ -228,6 +228,13 @@
return err
}
+ // Validate spec name.
+ if spec.Annotations.Name == "" {
+ spec.Annotations.Name = "default"
+ } else if spec.Annotations.Name != "default" {
+ return validationError{errors.New(`swarm spec must be named "default"`)}
+ }
+
// In update, client should provide the complete spec of the swarm, including
// Name and Labels. If a field is specified with 0 or nil, then the default value
// will be used to swarmkit.