force to validate whether engine's label is like format "key=value"

Signed-off-by: Sun Hongliang <allen.sun@daocloud.io>
This commit is contained in:
Sun Hongliang 2016-02-24 23:36:01 +08:00
parent a839ebdd06
commit aa6ff494e4
1 changed files with 4 additions and 0 deletions

View File

@ -423,6 +423,10 @@ func (e *Engine) updateSpecs() error {
}
for _, label := range info.Labels {
kv := strings.SplitN(label, "=", 2)
if len(kv) != 2 {
message := fmt.Sprintf("Engine (ID: %s, Addr: %s) contains an invalid label (%s) not formatted as \"key=value\".", e.ID, e.Addr, label)
return fmt.Errorf(message)
}
e.Labels[kv[0]] = kv[1]
}
return nil