Add a supported series helper function #159

Merged
merged 2 commits into from Sep 30, 2015

Conversation

Projects
None yet
3 participants
Owner

wallyworld commented Sep 30, 2015

Add a new SeriesToUse() helper for use by core and charmrepo.

charm.go
+// If the specified series is empty, the any default series defined by the
+// charm is used. Any specified series is validated against those supported
+// by the charm.
+func SeriesToUse(series string, supportedSeries []string) (string, error) {
@axw

axw Sep 30, 2015

Member

Rename the first parameter to "requestedSeries"? I think that would make its purpose a bit more obvious.

charm.go
+
+// SeriesToUse takes a specified series and a list of series supported by a
+// charm and returns the series which is relevant.
+// If the specified series is empty, the any default series defined by the
@axw

axw Sep 30, 2015

Member

s/the any/then any/

Is it really any? you're selecting the first one, and in the code you say "charm default". Is the charm default the first value in the list? If so, you should not say "any" here.

@wallyworld

wallyworld Sep 30, 2015

Owner

"any" needs to be read as "any default"
If the charm does not specify series, the default series is ""
The default is the first series specified, if any are specified.

@axw

axw Sep 30, 2015

Member

If you're saying it's written as intended, then I do not understand it. I would write it as:

If the requested series is empty, the charm's default series (first item in the supported series list) is used.

Is that correct?

charm.go
+// SeriesToUse takes a specified series and a list of series supported by a
+// charm and returns the series which is relevant.
+// If the specified series is empty, the any default series defined by the
+// charm is used. Any specified series is validated against those supported
@axw

axw Sep 30, 2015

Member

s/Any/The/

@wallyworld

wallyworld Sep 30, 2015

Owner

The specified series is optional, so any is appropriate here.

@wallyworld

wallyworld Sep 30, 2015

Owner

Reworded:

// If the requested series is empty, then any default series defined by the
// charm is used, otherwise the requested series is validated against those
// supported by the charm.

charm.go
+ if series == "" {
+ return supportedSeries[0], nil
+ }
+ // Ensure series is supported.
@axw

axw Sep 30, 2015

Member

code is self-evident, comment is unnecessary

Member

axw commented Sep 30, 2015

A few doc issues, otherwise LGTM. I don't like the name, but it'll do.

Owner

wallyworld commented Sep 30, 2015

$$merge$$

Contributor

jujubot commented Sep 30, 2015

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

jujubot added a commit that referenced this pull request Sep 30, 2015

Merge pull request #159 from wallyworld/series-helper
Add a supported series helper function

Add a new SeriesToUse() helper for use by core and charmrepo.

@jujubot jujubot merged commit 96e5746 into juju:v6-unstable Sep 30, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment