1
// Copyright 2016 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
4
package charmrepo // import "gopkg.in/juju/charmrepo.v2-unstable"
6
// This file may go away once Juju stops using anything here.
12
"gopkg.in/juju/charm.v6-unstable"
14
"gopkg.in/juju/charmrepo.v2-unstable/csclient"
15
"gopkg.in/juju/charmrepo.v2-unstable/csclient/params"
18
// URL returns the root endpoint URL of the charm store.
19
func (s *CharmStore) URL() string {
20
return s.client.ServerURL()
23
// Latest returns the most current revision for each of the identified
24
// charms. The revision in the provided charm URLs is ignored.
25
func (s *CharmStore) Latest(curls ...*charm.URL) ([]CharmRevision, error) {
26
results, err := s.client.Latest(curls)
31
var responses []CharmRevision
32
for i, result := range results {
33
response := CharmRevision{
34
Revision: result.Revision,
35
Sha256: result.Sha256,
38
if errgo.Cause(result.Err) == params.ErrNotFound {
39
curl := curls[i].WithRevision(-1)
40
response.Err = CharmNotFound(curl.String())
42
responses = append(responses, response)
47
// WithTestMode returns a repository Interface where test mode is enabled,
48
// meaning charm store download stats are not increased when charms are
50
func (s *CharmStore) WithTestMode() *CharmStore {
52
newRepo.client.DisableStats()
56
// JujuMetadataHTTPHeader is the HTTP header name used to send Juju metadata
57
// attributes to the charm store.
58
const JujuMetadataHTTPHeader = csclient.JujuMetadataHTTPHeader
60
// WithJujuAttrs returns a repository Interface with the Juju metadata
62
func (s *CharmStore) WithJujuAttrs(attrs map[string]string) *CharmStore {
64
header := make(http.Header)
65
for k, v := range attrs {
66
header.Add(JujuMetadataHTTPHeader, k+"="+v)
68
newRepo.client.SetHTTPHeader(header)