juju: github.com/juju/juju/charmstore Index | Files

package charmstore

import "github.com/juju/juju/charmstore"

Index

Package Files

charmid.go client.go fakeclient.go info.go jar.go latest.go

type ChannelAwareFakeClient Uses

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

ChannelAwareFakeClient is a charmstore client that stores the channel that its methods refer to across calls. That is, it is stateful. It is modelled on the Client type defined in gopkg.in/juju/charmrepo.v3/csclient.

Constructing ChannelAwareFakeClient

ChannelAwareFakeClient does not have a NewChannelAwareFakeClient method. To construct an instance, use the following pattern:

NewFakeClient(nil).WithChannel(channel)

Setting the channel

To set ChannelAwareFakeClient's channel, its the WithChannel method.

func (ChannelAwareFakeClient) AddDockerResource Uses

func (c ChannelAwareFakeClient) AddDockerResource(id *charm.URL, resourceName string, imageName, digest string) (revision int, err error)

AddDockerResource adds a docker resource against id.

func (ChannelAwareFakeClient) Get Uses

func (c ChannelAwareFakeClient) Get(path string, value interface{}) error

Get retrieves data from path. If nothing has been Put to path, an error satisfying errors.IsNotFound is returned.

func (ChannelAwareFakeClient) ListResources Uses

func (c ChannelAwareFakeClient) ListResources(id *charm.URL) ([]params.Resource, error)

ListResources returns Resource metadata for resources that have been uploaded to the repository for id. To upload a resource, use UploadResource. Although id is type *charm.URL, resources are not restricted to charms. That type is also used for other entities in the charmstore, such as bundles.

Returns an error that satisfies errors.IsNotFound when no resources are present for id.

func (ChannelAwareFakeClient) Publish Uses

func (c ChannelAwareFakeClient) Publish(id *charm.URL, channels []params.Channel, resources map[string]int) error

Publish marks id as published against channels within the charm store.

In this implementation, the resources parameter is ignored.

func (ChannelAwareFakeClient) Put Uses

func (c ChannelAwareFakeClient) Put(path string, value interface{}) error

Put uploads data to path, overwriting any data that is already present

func (ChannelAwareFakeClient) UploadBundle Uses

func (c ChannelAwareFakeClient) UploadBundle(id *charm.URL, bundle charm.Bundle) (*charm.URL, error)

UploadBundle takes a bundle's formal identifier (its URL) and its contents, then uploads it into the store for other clients to download.

Returns another charm identifier, which has had its revision set to the new revision, which will be 0 for the first revision or current revision in the store, plus 1.

func (ChannelAwareFakeClient) UploadBundleWithRevision Uses

func (c ChannelAwareFakeClient) UploadBundleWithRevision(id *charm.URL, bundle charm.Bundle, promulgatedRevision int) error

UploadBundleWithRevision takes a bundle's formal identifier (its URL) and its contents and a revision number, then uploads it into the store for other clients to download.

func (ChannelAwareFakeClient) UploadCharm Uses

func (c ChannelAwareFakeClient) UploadCharm(id *charm.URL, ch charm.Charm) (*charm.URL, error)

UploadCharm takes a charm's formal identifier (its URL) and its contents, then uploads it into the store for other clients to download.

Returns another charm identifier, which has had its revision set to the new revision, which will be 0 for the first revision or current revision in the store, plus 1.

func (ChannelAwareFakeClient) UploadCharmWithRevision Uses

func (c ChannelAwareFakeClient) UploadCharmWithRevision(id *charm.URL, ch charm.Charm, promulgatedRevision int) error

UploadCharmWithRevision takes a charm's formal identifier (its URL) and its contents and a revision number, then uploads it into the store for other clients to download.

func (ChannelAwareFakeClient) UploadResource Uses

func (c ChannelAwareFakeClient) UploadResource(id *charm.URL, name, path string, file io.ReaderAt, size int64, progress csclient.Progress) (revision int, err error)

UploadResource uploads a resource (an archive) into the store, tags it to a charm/bundle represented by id for other clients to download when they download the charm/bundle.

In this implementation, the progress parameter is ignored.

func (ChannelAwareFakeClient) WithChannel Uses

func (c ChannelAwareFakeClient) WithChannel(channel params.Channel) *ChannelAwareFakeClient

WithChannel returns a ChannelAwareFakeClient with its channel set to channel.

type CharmID Uses

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 Uses

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 Uses

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

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

type CharmInfoResult Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

func NewCustomClient(bakeryClient *httpbakery.Client, server string) (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 Uses

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 Uses

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 Uses

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

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

func (Client) ResourceInfo Uses

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

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

type FakeClient Uses

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

FakeClient is a stand-in for the gopkg.in/juju/charmrepo.v3/csclient Client type. Its "stores" data within several an in-memory map for each object that charmstores know about, primarily charms, bundles and resources.

An abridged session would look something like this, where charmId is a *charm.URL:

// initialise a new charmstore with an empty repository
repo := NewRepository()
client := NewFakeClient(repo)
client.UploadCharm(charmId)
// later on
charm := client.Get(charmId)

func NewFakeClient Uses

func NewFakeClient(repo *Repository) *FakeClient

NewFakeClient returns a FakeClient that is initialised with repo. If repo is nil, a blank Repository will be created.

func (FakeClient) AddDockerResource Uses

func (c FakeClient) AddDockerResource(id *charm.URL, resourceName string, imageName, digest string) (revision int, err error)

AddDockerResource adds a docker resource against id.

func (FakeClient) Get Uses

func (c FakeClient) Get(path string, value interface{}) error

Get retrieves data from path. If nothing has been Put to path, an error satisfying errors.IsNotFound is returned.

func (FakeClient) ListResources Uses

func (c FakeClient) ListResources(channel params.Channel, id *charm.URL) ([]params.Resource, error)

ListResources returns Resource metadata for resources that have been uploaded to the repository for id. To upload a resource, use UploadResource. Although id is type *charm.URL, resources are not restricted to charms. That type is also used for other entities in the charmstore, such as bundles.

Returns an error that satisfies errors.IsNotFound when no resources are present for id.

func (FakeClient) Publish Uses

func (c FakeClient) Publish(id *charm.URL, channels []params.Channel, resources map[string]int) error

Publish marks id as published against channels within the charm store.

In this implementation, the resources parameter is ignored.

func (FakeClient) Put Uses

func (c FakeClient) Put(path string, value interface{}) error

Put uploads data to path, overwriting any data that is already present

func (FakeClient) UploadBundle Uses

func (c FakeClient) UploadBundle(id *charm.URL, bundleData charm.Bundle) (*charm.URL, error)

UploadBundle takes a bundle's formal identifier (its URL) and its contents, then uploads it into the store for other clients to download.

Returns another charm identifier, which has had its revision set to the new revision, which will be 0 for the first revision or current revision in the store, plus 1.

func (FakeClient) UploadBundleWithRevision Uses

func (c FakeClient) UploadBundleWithRevision(id *charm.URL, bundleData charm.Bundle, promulgatedRevision int) error

UploadBundleWithRevision takes a bundle's formal identifier (its URL) and its contents and a revision number, then uploads it into the store for other clients to download.

func (FakeClient) UploadCharm Uses

func (c FakeClient) UploadCharm(id *charm.URL, charmData charm.Charm) (*charm.URL, error)

UploadCharm takes a charm's formal identifier (its URL) and its contents, then uploads it into the store for other clients to download.

Returns another charm identifier, which has had its revision set to the new revision, which will be 0 for the first revision or current revision in the store, plus 1.

func (FakeClient) UploadCharmWithRevision Uses

func (c FakeClient) UploadCharmWithRevision(id *charm.URL, charmData charm.Charm, promulgatedRevision int) error

UploadCharmWithRevision takes a charm's formal identifier (its URL) and its contents and a revision number, then uploads it into the store for other clients to download.

func (FakeClient) UploadResource Uses

func (c FakeClient) UploadResource(id *charm.URL, name, path string, file io.ReaderAt, size int64, progress csclient.Progress) (revision int, err error)

UploadResource uploads a resource (an archive) into the store, tags it to a charm/bundle represented by id for other clients to download when they download the charm/bundle.

In this implementation, the progress parameter is ignored.

func (FakeClient) WithChannel Uses

func (c FakeClient) WithChannel(channel params.Channel) *ChannelAwareFakeClient

WithChannel returns a ChannelAwareFakeClient with its channel set to channel and its other values originating from this client.

type MacaroonCache Uses

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 Repository Uses

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

Repository provides in-memory access to charms and other objects held in a charmstore (or locally), such as bundles and resources. Its intended use case is to act as a fake charmrepo for testing purposes.

Warnings

No guarantees are made that Repository maintains its invariants or that the behaviour matches the behaviour of the actual charm store. For example, Repository's information about which charm revisions it knows about is decoupled from the charm data that it currently stores.

Repository implements gopkg.in/juju/charmrepo Interface and derivative interfaces, such as github.com/juju/juju/cmd/juju/application DeployAPI.

func NewRepository Uses

func NewRepository() *Repository

NewRepository returns an empty Repository. To populate it with charms, bundles and resources use UploadCharm, UploadBundle and/or UploadResource.

func (Repository) AddCharm Uses

func (r Repository) AddCharm(id *charm.URL, channel params.Channel, force bool) error

AddCharm registers a charm's availability on a particular channel, but does not upload its contents. This is part of a two stage process for storing charms in the repository.

In this implementation, the force parameter is ignored.

func (Repository) AddCharmWithAuthorization Uses

func (r Repository) AddCharmWithAuthorization(id *charm.URL, channel params.Channel, macaroon *macaroon.Macaroon, force bool) error

AddCharmWithAuthorization is equivalent to AddCharm. The macaroon parameter is ignored.

func (Repository) AddLocalCharm Uses

func (r Repository) AddLocalCharm(id *charm.URL, details charm.Charm, force bool) (*charm.URL, error)

AddLocalCharm allows you to register a charm that is not associated with a particular release channel. Its purpose is to facilitate registering charms that have been built locally.

func (Repository) AuthorizeCharmstoreEntity Uses

func (r Repository) AuthorizeCharmstoreEntity(id *charm.URL) (*macaroon.Macaroon, error)

AuthorizeCharmstoreEntity returns (nil,nil) as Repository has no authorisation to manage

func (Repository) CharmInfo Uses

func (r Repository) CharmInfo(charmURL string) (*charms.CharmInfo, error)

CharmInfo returns information about charms that are currently in the charm store.

func (Repository) Get Uses

func (r Repository) Get(id *charm.URL) (charm.Charm, error)

Get retrieves a charm from the repository.

Part of the charmrepo.Interface

func (Repository) GetBundle Uses

func (r Repository) GetBundle(id *charm.URL) (charm.Bundle, error)

GetBundle retrieves a bundle from the repository.

Part of the charmrepo.Interface

func (Repository) ListResources Uses

func (r Repository) ListResources(id *charm.URL) ([]params.Resource, error)

ListResources returns Resource metadata for resources that have been uploaded to the repository for id. To upload a resource, use UploadResource. Although id is type *charm.URL, resources are not restricted to charms. That type is also used for other entities in the charmstore, such as bundles.

Returns an error that satisfies errors.IsNotFound when no resources are present for id.

func (Repository) Publish Uses

func (r Repository) Publish(id *charm.URL, channels []params.Channel, resources map[string]int) error

Publish marks a charm or bundle as published within channels.

In this implementation, the resources parameter is ignored.

func (Repository) Resolve Uses

func (r Repository) Resolve(ref *charm.URL) (canonRef *charm.URL, supportedSeries []string, err error)

Resolve disambiguates a charm to a specific revision.

Part of the charmrepo.Interface

func (Repository) ResolveWithPreferredChannel Uses

func (r Repository) ResolveWithPreferredChannel(ref *charm.URL, preferredChannel params.Channel) (*charm.URL, params.Channel, []string, error)

ResolveWithChannel disambiguates a charm to a specific revision.

Part of the cmd/juju/application.DeployAPI interface

func (Repository) UploadBundle Uses

func (r Repository) UploadBundle(id *charm.URL, bundleData charm.Bundle) (*charm.URL, error)

UploadBundle takes a bundle's formal identifier (its URL) and its contents, then uploads it into the store for other clients to download.

Returns another charm identifier, which has had its revision set to the new revision, which will be 0 for the first revision or current revision in the store, plus 1.

func (Repository) UploadBundleWithRevision Uses

func (r Repository) UploadBundleWithRevision(id *charm.URL, bundleData charm.Bundle, promulgatedRevision int) error

UploadBundleWithRevision takes a bundle's formal identifier (its URL) and its contents and a revision number, then uploads it into the store for other clients to download.

func (Repository) UploadCharm Uses

func (r Repository) UploadCharm(id *charm.URL, charmData charm.Charm) (*charm.URL, error)

UploadCharm takes a charm's formal identifier (its URL) and its contents, then uploads it into the store for clients to download.

Returns another charm identifier, which has had its revision set to the new revision, which will be 0 for the first revision or current revision in the store, plus 1.

func (Repository) UploadCharmWithRevision Uses

func (r Repository) UploadCharmWithRevision(id *charm.URL, charmData charm.Charm, promulgatedRevision int) error

UploadCharmWithRevision takes a charm's formal identifier (its URL) and its contents and a revision number, then uploads it into the store for clients to download.

func (Repository) UploadResource Uses

func (r Repository) UploadResource(id *charm.URL, name, path string, file io.ReaderAt, size int64, progress csclient.Progress) (revision int, err error)

UploadResource uploads a resource (an archive) into the store, tags it to a charm/bundle represented by id for other clients to download when they download the charm/bundle.

In this implementation, the progress parameter is ignored.

type ResourceData Uses

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 Uses

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.

Package charmstore imports 21 packages (graph) and is imported by 223 packages. Updated 2019-08-23. Refresh now. Tools for package owners.