appc/spec — pull request #64 by jonboulle (2014-12-30 02:19:16+00:00)
Title: Label uniqueness and thoughts about converting them to a map

Hi,

* Should labels name be unique (no multiple labels with same name) (as I see in discovery/parse.go that uses a map[string]string and on NewAppFromString checks for duplicate labels)?

If so:

* Perhaps the spec should clarify this.
* schema/types/labels.go, with the actual implementation, should verify this on Marshal and Unmarshal.

I was also thinking about converting them to a map[ACName]string (that on marshal will become a json object) like already done with "annotations". This will have some benefits and a possible downside:

* No need to verify duplicate labels.
* There's a possible downside: if the provided json contains duplicate keys, go's json will take the last one without reporting any duplicate key error (the json spec is not clear on duplicate keys and looks like they are allowed).
* Less verbose json for labels.
* By now discovery uses a map[string]string while types.Label uses a struct, there'll be a need to convert between them and validate them. Making all them use types.Labels defined as map[ACName]string will avoid conversions.
* No need to Get and Set functions that should verify duplicate labels every time but coders can work with the typical go's map pattern.

Thanks!