charmrepo

package
v5.0.0-...-949f52b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2016 License: LGPL-3.0 Imports: 18 Imported by: 21

Documentation

Index

Constants

View Source
const JujuMetadataHTTPHeader = "Juju-Metadata"

JujuMetadataHTTPHeader is the HTTP header name used to send Juju metadata attributes to the charm store.

Variables

View Source
var CacheDir string

CacheDir stores the charm cache directory path.

View Source
var LegacyStore = &LegacyCharmStore{BaseURL: "https://store.juju.ubuntu.com"}

Functions

func CharmNotFound

func CharmNotFound(url string) error

func Latest

func Latest(repo Interface, curl *charm.URL) (int, error)

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.

Types

type CharmRevision

type CharmRevision struct {
	Revision int
	Sha256   string
	Err      error
}

CharmRevision holds the revision number of a charm and any error encountered in retrieving it.

type CharmStore

type CharmStore struct {
	// contains filtered or unexported fields
}

CharmStore is a repository Interface that provides access to the public Juju charm store.

func (*CharmStore) Get

func (s *CharmStore) Get(curl *charm.URL) (charm.Charm, error)

Get implements Interface.Get.

func (*CharmStore) Latest

func (s *CharmStore) Latest(curls ...*charm.URL) ([]CharmRevision, error)

Latest implements Interface.Latest.

func (*CharmStore) Resolve

func (s *CharmStore) Resolve(ref *charm.Reference) (*charm.URL, error)

Resolve implements Interface.Resolve.

func (*CharmStore) URL

func (s *CharmStore) URL() string

URL returns the root endpoint URL of the charm store.

func (*CharmStore) WithJujuAttrs

func (s *CharmStore) WithJujuAttrs(attrs map[string]string) Interface

WithJujuAttrs returns a repository Interface with the Juju metadata attributes set.

func (*CharmStore) WithTestMode

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

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

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

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

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.

func LegacyInferRepository

func LegacyInferRepository(ref *charm.Reference, localRepoPath string) (repo Interface, err error)

LegacyInferRepository returns a charm repository inferred from the provided charm or bundle reference. Local references will use the provided path.

func NewCharmStore

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.

func NewLocalRepository

func NewLocalRepository(path string) (Interface, error)

NewLocalRepository creates and return a new local Juju repository pointing to the given local path.

type LegacyCharmStore

type LegacyCharmStore struct {
	BaseURL string
	// contains filtered or unexported fields
}

LegacyCharmStore is a repository Interface that provides access to the legacy Juju charm store.

func (*LegacyCharmStore) BranchLocation

func (s *LegacyCharmStore) BranchLocation(curl *charm.URL) string

BranchLocation returns the location for the branch holding the charm at curl.

func (*LegacyCharmStore) CharmURL

func (s *LegacyCharmStore) CharmURL(location string) (*charm.URL, error)

CharmURL returns the charm URL for the branch at location.

func (*LegacyCharmStore) Event

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.

func (*LegacyCharmStore) Get

func (s *LegacyCharmStore) Get(curl *charm.URL) (charm.Charm, error)

Get returns the charm referenced by curl. CacheDir must have been set, otherwise Get will panic.

func (*LegacyCharmStore) Info

func (s *LegacyCharmStore) Info(curls ...charm.Location) ([]*InfoResponse, error)

Info returns details for all the specified charms in the charm store.

func (*LegacyCharmStore) Latest

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.

func (*LegacyCharmStore) Resolve

func (s *LegacyCharmStore) Resolve(ref *charm.Reference) (*charm.URL, error)

Resolve canonicalizes charm URLs any implied series in the reference.

func (*LegacyCharmStore) WithAuthAttrs

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 (*LegacyCharmStore) WithJujuAttrs

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 (*LegacyCharmStore) WithTestMode

func (s *LegacyCharmStore) WithTestMode(testMode bool) Interface

WithTestMode returns a repository Interface where testMode is set to value passed to this method.

type LocalRepository

type LocalRepository struct {
	Path string
}

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/

func (*LocalRepository) Get

func (r *LocalRepository) Get(curl *charm.URL) (charm.Charm, error)

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 (*LocalRepository) Latest

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.

func (*LocalRepository) Resolve

func (r *LocalRepository) Resolve(ref *charm.Reference) (*charm.URL, error)

Resolve implements Interface.Resolve.

type NewCharmStoreParams

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

type NotFoundError struct {
	// contains filtered or unexported fields
}

NotFoundError represents an error indicating that the requested data wasn't found.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL