import "gopkg.in/juju/charm.v5/charmrepo"
charmstore.go legacy.go local.go params.go repo.go
const JujuMetadataHTTPHeader = "Juju-Metadata"JujuMetadataHTTPHeader is the HTTP header name used to send Juju metadata attributes to the charm store.
CacheDir stores the charm cache directory path.
var LegacyStore = &LegacyCharmStore{BaseURL: "https://store.juju.ubuntu.com"}
Latest returns the latest revision of the charm referenced by curl, regardless of the revision set on each curl. This is a helper which calls the bulk method and unpacks a single result.
CharmRevision holds the revision number of a charm and any error encountered in retrieving it.
type CharmStore struct {
// contains filtered or unexported fields
}CharmStore is a repository Interface that provides access to the public Juju charm store.
Get implements Interface.Get.
func (s *CharmStore) Latest(curls ...*charm.URL) ([]CharmRevision, error)
Latest implements Interface.Latest.
Resolve implements Interface.Resolve.
func (s *CharmStore) URL() string
URL returns the root endpoint URL of the charm store.
func (s *CharmStore) WithJujuAttrs(attrs map[string]string) Interface
WithJujuAttrs returns a repository Interface with the Juju metadata attributes set.
func (s *CharmStore) WithTestMode() Interface
WithTestMode returns a repository Interface where test mode is enabled, meaning charm store download stats are not increased when charms are retrieved.
type EventResponse struct {
Kind string `json:"kind"`
Revision int `json:"revision"` // Zero is valid. Can't omitempty.
Digest string `json:"digest,omitempty"`
Errors []string `json:"errors,omitempty"`
Warnings []string `json:"warnings,omitempty"`
Time string `json:"time,omitempty"`
}EventResponse is sent by the charm store in response to charm-event requests.
type InfoResponse struct {
CanonicalURL string `json:"canonical-url,omitempty"`
Revision int `json:"revision"` // Zero is valid. Can't omitempty.
Sha256 string `json:"sha256,omitempty"`
Digest string `json:"digest,omitempty"`
Errors []string `json:"errors,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}InfoResponse is sent by the charm store in response to charm-info requests.
type Interface interface {
// Get returns the charm referenced by curl.
Get(curl *charm.URL) (charm.Charm, error)
// Latest returns the latest revision of the charms referenced by curls,
// regardless of the revision set on each curl.
Latest(curls ...*charm.URL) ([]CharmRevision, error)
// Resolve resolves the series and revision of the given entity
// reference. If the series is not specified, it may be resolved
// by the charm store or rejected. After the series is resolved,
// if the revision is not specified, it will be resolved to the latest
// available revision for that series.
Resolve(ref *charm.Reference) (*charm.URL, error)
}Interface represents a charm repository (a collection of charms).
func InferRepository(ref *charm.Reference, charmStoreParams NewCharmStoreParams, localRepoPath string) (Interface, error)
InferRepository returns a charm repository inferred from the provided charm or bundle reference. Charm store references will use the provided parameters. Local references will use the provided path.
LegacyInferRepository returns a charm repository inferred from the provided charm or bundle reference. Local references will use the provided path.
func NewCharmStore(p NewCharmStoreParams) Interface
NewCharmStore creates and returns a charm store repository. The given parameters are used to instantiate the charm store.
The errors returned from the interface methods will preserve the causes returned from the underlying csclient methods.
NewLocalRepository creates and return a new local Juju repository pointing to the given local path.
LegacyCharmStore is a repository Interface that provides access to the legacy Juju charm store.
func (s *LegacyCharmStore) BranchLocation(curl *charm.URL) string
BranchLocation returns the location for the branch holding the charm at curl.
CharmURL returns the charm URL for the branch at location.
func (s *LegacyCharmStore) Event(curl *charm.URL, digest string) (*EventResponse, error)
Event returns details for a charm event in the charm store.
If digest is empty, the latest event is returned.
Get returns the charm referenced by curl. CacheDir must have been set, otherwise Get will panic.
func (s *LegacyCharmStore) Info(curls ...charm.Location) ([]*InfoResponse, error)
Info returns details for all the specified charms in the charm store.
func (s *LegacyCharmStore) Latest(curls ...*charm.URL) ([]CharmRevision, error)
Latest returns the latest revision of the charms referenced by curls, regardless of the revision set on each curl.
Resolve canonicalizes charm URLs any implied series in the reference.
func (s *LegacyCharmStore) WithAuthAttrs(authAttrs string) Interface
WithAuthAttrs return a repository Interface with the authentication token list set. authAttrs is a list of attr=value pairs.
func (s *LegacyCharmStore) WithJujuAttrs(jujuAttrs string) Interface
WithJujuAttrs returns a repository Interface with the Juju metadata attributes set. jujuAttrs is a list of attr=value pairs.
func (s *LegacyCharmStore) WithTestMode(testMode bool) Interface
WithTestMode returns a repository Interface where testMode is set to value passed to this method.
LocalRepository represents a local directory containing subdirectories named after an Ubuntu series, each of which contains charms targeted for that series. For example:
/path/to/repository/oneiric/mongodb/ /path/to/repository/precise/mongodb.charm /path/to/repository/precise/wordpress/
Get returns a charm matching curl, if one exists. If curl has a revision of -1, it returns the latest charm that matches curl. If multiple candidates satisfy the foregoing, the first one encountered will be returned.
func (r *LocalRepository) Latest(curls ...*charm.URL) ([]CharmRevision, error)
Latest implements Interface.Latest by finding the latest revision of each of the given charm URLs in the local repository.
Resolve implements Interface.Resolve.
type NewCharmStoreParams struct {
// URL holds the root endpoint URL of the charm store,
// with no trailing slash, not including the version.
// For example https://api.jujucharms.com/charmstore
// If empty, the default charm store client location is used.
URL string
// HTTPClient holds the HTTP client to use when making
// requests to the store. If nil, httpbakery.NewHTTPClient will
// be used.
HTTPClient *http.Client
// VisitWebPage is called when authorization requires that
// the user visits a web page to authenticate themselves.
// If nil, a default function that returns an error will be used.
VisitWebPage func(url *url.URL) error
}NewCharmStoreParams holds parameters for instantiating a new CharmStore.
type NotFoundError struct {
// contains filtered or unexported fields
}NotFoundError represents an error indicating that the requested data wasn't found.
func (e *NotFoundError) Error() string
Package charmrepo imports 18 packages (graph) and is imported by 77 packages. Updated 2016-11-12. Refresh now. Tools for package owners.