charmrepo

package module
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: LGPL-3.0 Imports: 21 Imported by: 12

README

charmrepo

Charm repositories and charmstore client packages

Documentation

Index

Constants

View Source
const JujuMetadataHTTPHeader = csclient.JujuMetadataHTTPHeader

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 BundleNotFound

func BundleNotFound(url string) error

BundleNotFound returns an error indicating that the bundle at the specified URL does not exist.

func CharmNotFound

func CharmNotFound(url string) error

CharmNotFound returns an error indicating that the charm at the specified URL does not exist.

func InvalidPath

func InvalidPath(path string) error

InvalidPath returns an invalidPathError.

func IsInvalidPathError

func IsInvalidPathError(err error) bool

func NewBundleAtPath

func NewBundleAtPath(path string) (charm.Bundle, *charm.URL, error)

NewBundleAtPath creates and returns a bundle at a given path, and a URL that describes it.

func NewCharmAtPath

func NewCharmAtPath(path, series string) (charm.Charm, *charm.URL, error)

NewCharmAtPath returns the charm represented by this path, and a URL that describes it. If the series is empty, the charm's default series is used, if any. Otherwise, the series is validated against those the charm declares it supports.

func NewCharmAtPathForceSeries

func NewCharmAtPathForceSeries(path, series string, force bool) (charm.Charm, *charm.URL, error)

NewCharmAtPathForSeries returns the charm represented by this path, and a URL that describes it. If the series is empty, the charm's default series is used, if any. Otherwise, the series is validated against those the charm declares it supports. If force is true, then any series validation errors are ignored and the requested series is used regardless. Note though that is it still an error if the series is not specified and the charm does not define any.

func ReadBundleFile

func ReadBundleFile(path string) (*charm.BundleData, error)

ReadBundleFile attempts to read the file at path and interpret it as a bundle.

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 NewCharmStore

func NewCharmStore(p NewCharmStoreParams) *CharmStore

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 NewCharmStoreFromClient

func NewCharmStoreFromClient(client *csclient.Client) *CharmStore

NewCharmStoreFromClient creates and returns a charm store repository. The provided client is used for charm store requests.

func (*CharmStore) Client

func (s *CharmStore) Client() *csclient.Client

Client returns the charmstore client that the CharmStore implementation uses under the hood.

func (*CharmStore) Get

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

Get implements Interface.Get.

func (*CharmStore) GetBundle

func (s *CharmStore) GetBundle(curl *charm.URL) (charm.Bundle, error)

GetBundle implements Interface.GetBundle.

func (*CharmStore) Latest

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

Latest returns the most current revision for each of the identified charms. The revision in the provided charm URLs is ignored.

func (*CharmStore) Resolve

func (s *CharmStore) Resolve(ref *charm.URL) (*charm.URL, []string, error)

Resolve implements Interface.Resolve.

func (*CharmStore) ResolveWithChannel

func (s *CharmStore) ResolveWithChannel(ref *charm.URL) (*charm.URL, params.Channel, []string, error)

ResolveWithChannel does the same thing as Resolve() but also returns the best channel to use.

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) *CharmStore

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

func (*CharmStore) WithTestMode

func (s *CharmStore) WithTestMode() *CharmStore

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)

	// GetBundle returns the bundle referenced by curl.
	GetBundle(curl *charm.URL) (charm.Bundle, error)

	// Resolve resolves the given reference to a canonical form which refers
	// unambiguously to a specific revision of an entity. If the entity
	// is a charm that may support more than one series, canonRef.Series will
	// be empty and supportedSeries will hold the list of series supported by
	// the charm with the preferred series first.
	// If ref holds a series, then Resolve will always ensure that the returned
	// entity supports that series.
	Resolve(ref *charm.URL) (canonRef *charm.URL, supportedSeries []string, err error)
}

Interface represents a charm repository (a collection of charms).

func InferRepository

func InferRepository(ref *charm.URL, 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.URL, 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 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) GetBundle

func (s *LegacyCharmStore) GetBundle(curl *charm.URL) (charm.Bundle, error)

GetBundle is only defined for implementing Interface.

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.URL) (*charm.URL, []string, 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) GetBundle

func (r *LocalRepository) GetBundle(curl *charm.URL) (charm.Bundle, error)

GetBundle implements Interface.GetBundle.

func (*LocalRepository) Resolve

func (r *LocalRepository) Resolve(ref *charm.URL) (*charm.URL, []string, 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

	// BakeryClient holds the bakery client to use when making
	// requests to the store. This is used in preference to
	// HTTPClient.
	BakeryClient *httpbakery.Client

	// 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, no interaction will be allowed. This field
	// is ignored if BakeryClient is provided.
	VisitWebPage func(url *url.URL) error

	// User holds the name to authenticate as for the client. If User is empty,
	// no credentials will be sent.
	User string

	// Password holds the password for the given user, for authenticating the
	// client.
	Password string
}

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

type ResourceResult

type ResourceResult struct {
	Resources []resource.Resource
	Err       error
}

ResourceResult holds the resources for a given charm and any error encountered in retrieving them.

Directories

Path Synopsis
The csclient package provides access to the charm store API.
The csclient package provides access to the charm store API.
params
The params package holds types that are a part of the charm store's external contract - they will be marshalled (or unmarshalled) as JSON and delivered through the HTTP API.
The params package holds types that are a part of the charm store's external contract - they will be marshalled (or unmarshalled) as JSON and delivered through the HTTP API.

Jump to

Keyboard shortcuts

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