charmstore

package
v0.0.0-...-9ec3720 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const MacaroonURI = "github.com/juju/juju"

MacaroonURI is use when register new Juju checkers with the bakery.

Variables

View Source
var MacaroonNamespace = checkers.NewNamespace(map[string]string{MacaroonURI: ""})

MacaroonNamespace is the namespace Juju uses for managing macaroons.

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

	// Metadata is optional extra information about a particular model's
	// "in-theatre" use use of the charm.
	Metadata map[string]string
}

CharmID encapsulates data for identifying a unique charm from the charm store.

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 []resource.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. Note that 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 string) (Client, error)

NewCachingClient returns a Juju charm store client that stores and retrieves macaroons for calls in the given cache. The client will use server as the charmstore url.

func NewCustomClient

func NewCustomClient(base csWrapper) Client

func NewCustomClientAtURL

func NewCustomClientAtURL(bakeryClient *httpbakery.Client, server string) (Client, error)

NewCustomClientAtURL 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, modelMetadata 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) ([][]resource.Resource, error)

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

func (Client) ResourceInfo

func (c Client) ResourceInfo(req ResourceRequest) (resource.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 resource.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