Skip to content

Commit

Permalink
Network extensions: fix labels marshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Wilkie committed Apr 14, 2015
1 parent c409b71 commit c3c2dd8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions api/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,12 +1126,21 @@ func getLabels(body map[string]interface{}) (map[string]string, error) {
return nil, fmt.Errorf("Must specify Labels")
}

value, ok := inf.(map[string]string)
value, ok := inf.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("Labels must be a map[string]string")
}

return value, nil
result := make(map[string]string)
for k, v := range value {
val, ok := v.(string)
if !ok {
return nil, fmt.Errorf("Labels must be a map[string]string")
}
result[k] = val
}

return result, nil
}

func postNetworkCreate(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
Expand Down

0 comments on commit c3c2dd8

Please sign in to comment.