Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make MAAS2 constraint matches lists #51

Merged
merged 3 commits into from
Apr 28, 2016

Conversation

babbageclunk
Copy link
Contributor

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.

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.
matches := values.([]interface{})
interfaces := make([]Interface, 0, len(matches))
for _, value := range matches {
id := value.(int)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is really clunky because of all the extra casting needed - is there a better way of doing this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@babbageclunk
Copy link
Contributor Author

That seems a bit better without going quite so far.

@voidspace
Copy link

LGTM

@babbageclunk
Copy link
Contributor Author

$$merge$$

@jujubot
Copy link
Contributor

jujubot commented Apr 28, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-gomaasapi

@jujubot jujubot merged commit 3b0458b into juju:master Apr 28, 2016
@babbageclunk babbageclunk deleted the maas2-constraint-matches branch April 28, 2016 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants