charmrepo

package module
v6.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: LGPL-3.0 Imports: 16 Imported by: 2

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

This section is empty.

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
	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, archivePath string) (*charm.CharmArchive, error)

Get implements Interface.Get.

func (*CharmStore) GetBundle

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

GetBundle implements Interface.GetBundle.

func (*CharmStore) GetFileFromArchive

func (s *CharmStore) GetFileFromArchive(charmURL *charm.URL, filename string) (io.ReadCloser, error)

GetFileFromArchive streams the contents of the requested filename from the given charm or bundle archive, returning a reader its data can be read from.

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) Meta

func (s *CharmStore) Meta(charmURL *charm.URL, result interface{}) (*charm.URL, error)

Meta fetches metadata on the charm or bundle with the given id. The result value provides a value to be filled in with the result, which must be a pointer to a struct containing members corresponding to possible metadata include parameters (see https://github.com/juju/charmstore/blob/v4/docs/API.md#get-idmeta).

It returns the fully qualified id of the entity.

The name of the struct member is translated to a lower case hyphen-separated form; for example, ArchiveSize becomes "archive-size", and BundleMachineCount becomes "bundle-machine-count", but may also be specified in the field's tag

This example will fill in the result structure with information about the given id, including information on its archive size (include archive-size), upload time (include archive-upload-time) and digest (include extra-info/digest).

var result struct {
	ArchiveSize params.ArchiveSizeResponse
	ArchiveUploadTime params.ArchiveUploadTimeResponse
	Digest string `csclient:"extra-info/digest"`
}
id, err := client.Meta(id, &result)

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) ResolveWithPreferredChannel

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

ResolveWithPreferredChannel does the same thing as ResolveWithChannel() but allows callers to specify a preferred 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 reads the charm referenced by curl into a file
	// with the given path, which will be created if needed. Note that
	// the path's parent directory must already exist.
	Get(curl *charm.URL, archivePath string) (*charm.CharmArchive, error)

	// GetBundle returns the bundle referenced by curl.
	GetBundle(curl *charm.URL, archivePath string) (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).

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

	// 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