charmstore

package
v0.0.0-...-6cf1bc9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2016 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CharmID

type CharmID struct {
	// URL is the url of the charm.
	URL *charm.URL

	// Channel is the channel in which the charm was published.
	Channel csparams.Channel
}

CharmID is a type that encapsulates all the data required to interact with a unique charm from the charmstore.

type CharmInfo

type CharmInfo struct {
	// OriginalURL is charm URL, including its revision, for which we
	// queried the charm store.
	OriginalURL *charm.URL

	// Timestamp indicates when the info came from the charm store.
	Timestamp time.Time

	// LatestRevision identifies the most recent revision of the charm
	// that is available in the charm store.
	LatestRevision int

	// LatestResources is the list of resource info for each of the
	// charm's resources. This list is accurate as of the time that the
	// charm store handled the request for the charm info.
	LatestResources []charmresource.Resource
}

CharmInfo holds the information about a charm from the charm store. The info relates to the charm at a particular revision at the time the charm store handled the request. The resource revisions associated with the charm at that revision may change at any time. Note, however, that the set of resource names remains fixed for any given charm revision.

func (CharmInfo) LatestURL

func (info CharmInfo) LatestURL() *charm.URL

LatestURL returns the charm URL for the latest revision of the charm.

type CharmInfoResult

type CharmInfoResult struct {
	CharmInfo

	// Error indicates a problem retrieving or processing the info
	// for this charm.
	Error error
}

CharmInfoResult holds the result of a charm store request for info about a charm.

func LatestCharmInfo

func LatestCharmInfo(client Client, charms []CharmID, metadata map[string]string) ([]CharmInfoResult, error)

LatestCharmInfo returns the most up-to-date information about each of the identified charms at their latest revision. The revisions in the provided URLs are ignored. The returned map indicates charm URLs where the macaroon has been updated. This updated macaroon should be stored for use in any further requests. Note that this map may be non-empty even if this method returns an error (and the macaroons should be stored).

type CharmRevision

type CharmRevision struct {
	// Revision is newest revision for the charm.
	Revision int

	// Err holds any error that occurred while making the request.
	Err error
}

CharmRevision holds the data returned from the charmstore about the latest revision of a charm. Notet hat this may be different per channel.

type Client

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

Client wraps charmrepo/csclient (the charm store's API client library) in a higher level API.

func NewCachingClient

func NewCachingClient(cache MacaroonCache, server *url.URL) (Client, error)

NewCachingClient returns a Juju charm store client that stores and retrieves macaroons for calls in the given cache. If not nil, the client will use server as the charmstore url, otherwise it will default to the standard juju charmstore url.

func NewCustomClient

func NewCustomClient(bakeryClient *httpbakery.Client, server *url.URL) (Client, error)

NewCustomClient returns a juju charmstore client that relies on the passed-in httpbakery.Client to store and retrieve macaroons. If not nil, the client will use server as the charmstore url, otherwise it will default to the standard juju charmstore url.

func (Client) GetResource

func (c Client) GetResource(req ResourceRequest) (data ResourceData, err error)

GetResource returns the data (bytes) and metadata for a resource from the charmstore.

func (Client) LatestRevisions

func (c Client) LatestRevisions(charms []CharmID, metadata map[string][]string) ([]CharmRevision, error)

LatestRevisions returns the latest revisions of the given charms, using the given metadata.

func (Client) ListResources

func (c Client) ListResources(charms []CharmID) ([][]charmresource.Resource, error)

ListResources returns a list of resources for each of the given charms.

func (Client) ResourceInfo

func (c Client) ResourceInfo(req ResourceRequest) (charmresource.Resource, error)

ResourceInfo returns the metadata for the given resource from the charmstore.

type MacaroonCache

type MacaroonCache interface {
	Set(*charm.URL, macaroon.Slice) error
	Get(*charm.URL) (macaroon.Slice, error)
}

MacaroonCache represents a value that can store and retrieve macaroons for charms. It is used when we are requesting data from the charmstore for private charms.

type ResourceData

type ResourceData struct {
	// ReadCloser holds the bytes for the resource.
	io.ReadCloser

	// Resource holds the metadata for the resource.
	Resource charmresource.Resource
}

ResourceData represents the response from the charmstore about a request for resource bytes.

type ResourceRequest

type ResourceRequest struct {
	// Charm is the URL of the charm for which we're requesting a resource.
	Charm *charm.URL

	// Channel is the channel from which to request the resource info.
	Channel csparams.Channel

	// Name is the name of the resource we're asking about.
	Name string

	// Revision is the specific revision of the resource we're asking about.
	Revision int
}

ResourceRequest is the data needed to request a resource from the charmstore.

Jump to

Keyboard shortcuts

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