Skip to content

Commit

Permalink
Get the channel from the CharmStore.ResolveWithChannel() call.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Apr 8, 2016
1 parent 068410f commit 0a4b338
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions cmd/juju/service/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,15 @@ func (r *charmURLResolver) resolve(urlStr string) (*charm.URL, csparams.Channel,
if err != nil {
return nil, noChannel, nil, nil, errors.Trace(err)
}
var repo charmrepo.Interface
switch url.Schema {
case "cs":
repo = r.csRepo
repo := config.SpecializeCharmRepo(r.csRepo, r.conf).(*charmrepo.CharmStore)

resultUrl, channel, supportedSeries, err := repo.ResolveWithChannel(url)
if err != nil {
return nil, noChannel, nil, nil, errors.Trace(err)
}
return resultUrl, channel, supportedSeries, repo, nil
case "local":
if url.Series == "" {
if defaultSeries, ok := r.conf.DefaultSeries(); ok {
Expand All @@ -109,21 +114,20 @@ func (r *charmURLResolver) resolve(urlStr string) (*charm.URL, csparams.Channel,
logger.Errorf("The series is not specified in the model (default-series) or with the charm. Did you mean:\n\t%s", &possibleURL)
return nil, noChannel, nil, nil, errors.Errorf("cannot resolve series for charm: %q", url)
}
repo, err = charmrepo.NewLocalRepository(r.repoPath)
repo, err := charmrepo.NewLocalRepository(r.repoPath)
if err != nil {
return nil, noChannel, nil, nil, errors.Mask(err)
}
repo = config.SpecializeCharmRepo(repo, r.conf)

resultUrl, supportedSeries, err := repo.Resolve(url)
if err != nil {
return nil, noChannel, nil, nil, errors.Trace(err)
}
return resultUrl, noChannel, supportedSeries, repo, nil
default:
return nil, noChannel, nil, nil, errors.Errorf("unknown schema for charm reference %q", urlStr)
}
repo = config.SpecializeCharmRepo(repo, r.conf)
// TODO(ericsnow) repo.Resolve should give us the actual channel.
channel := noChannel
resultUrl, supportedSeries, err := repo.Resolve(url)
if err != nil {
return nil, noChannel, nil, nil, errors.Trace(err)
}
return resultUrl, channel, supportedSeries, repo, nil
}

// addCharmFromURL calls the appropriate client API calls to add the
Expand Down

0 comments on commit 0a4b338

Please sign in to comment.