Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Make MAAS2 constraint matches lists #51
+201
−38
Conversation
babbageclunk
added some commits
Apr 28, 2016
babbageclunk
reviewed
Apr 28, 2016
| + matches := values.([]interface{}) | ||
| + interfaces := make([]Interface, 0, len(matches)) | ||
| + for _, value := range matches { | ||
| + id := value.(int) |
babbageclunk
Apr 28, 2016
Member
This block is really clunky because of all the extra casting needed - is there a better way of doing this?
dimitern
Apr 28, 2016
Contributor
As discussed on IRC, I think it will be a lot simpler to parse the constraints map via an internal struct type (with possibly embedded types for storage and interfaces) with JSON tags on the fields.
|
That seems a bit better without going quite so far. |
|
LGTM |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-gomaasapi |
jujubot
merged commit 3b0458b
into
juju:master
Apr 28, 2016
babbageclunk
deleted the
babbageclunk:maas2-constraint-matches
branch
Apr 28, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
babbageclunk commentedApr 28, 2016
In APIv2 the constraint matches are actually label -> [id, id...]. This makes sense because in v1 they were id -> label, which meant that label could appear more than once; there could be multiple interfaces or storage devices that fulfil a specific constraint.
Change ConstraintMatches and the parsing to handle this.