charm

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultChannelString represents the default track and risk if nothing
	// is found.
	DefaultChannelString = "latest/stable"
)

Variables

View Source
var (
	// DefaultChannel represents the default track and risk.
	DefaultChannel = charm.Channel{
		Track: "latest",
		Risk:  charm.Stable,
	}
	// DefaultRiskChannel represents the default only risk channel.
	DefaultRiskChannel = charm.Channel{
		Risk: charm.Stable,
	}
)

Functions

func CharmNotFound

func CharmNotFound(url string) error

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

func ComputedSeries

func ComputedSeries(c charm.CharmMeta) (seriesSlice []string, _ error)

ComputedSeries of a charm, preserving legacy behavior. If the charm has no manifest, return series from the metadata. Otherwise return the series listed in the manifest Bases as channels.

func InvalidPath

func InvalidPath(path string) error

InvalidPath returns an invalidPathError.

func IsInvalidPathError

func IsInvalidPathError(err error) bool

func IsKubernetes

func IsKubernetes(cm charm.CharmMeta) bool

IsKubernetes reports whether the given charm should be deployed to Kubernetes, that is, a v1 charm with series "kubernetes", or a v2 charm with containers specified.

func IsUnsupportedSeriesError

func IsUnsupportedSeriesError(err error) bool

IsUnsupportedSeriesError returns true if err is an UnsupportedSeriesError.

func MakeRiskOnlyChannel

func MakeRiskOnlyChannel(risk string) charm.Channel

MakeRiskOnlyChannel creates a charm channel that is backwards compatible with old style charm store channels. This creates a risk aware channel only. No validation is performed on the risk and is just accepted as is.

func MustParseChannel

func MustParseChannel(s string) charm.Channel

MustParseChannel parses a given string or returns a panic.

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 NewUnsupportedSeriesError

func NewUnsupportedSeriesError(requestedSeries string, supportedSeries []string) error

NewUnsupportedSeriesError returns an error indicating that the requested series is not supported by a charm.

Types

type CharmArchive

type CharmArchive interface {
	charm.Charm

	Version() string
	LXDProfile() *charm.LXDProfile
}

CharmArchive provides information about a downloaded charm archive.

type EssentialMetadata

type EssentialMetadata struct {
	ResolvedOrigin Origin

	Meta     *charm.Meta
	Manifest *charm.Manifest
	Config   *charm.Config
}

EssentialMetadata encapsulates the essential metadata required for deploying a particular charm.

type MetadataFormat

type MetadataFormat int

MetadataFormat of the parsed charm.

const (
	FormatUnknown MetadataFormat = iota
	FormatV1      MetadataFormat = iota
	FormatV2      MetadataFormat = iota
)

MetadataFormat are the different versions of charm metadata supported.

func Format

func Format(ch charm.CharmMeta) MetadataFormat

Format returns the metadata format for a given charm.

type MetadataRequest

type MetadataRequest struct {
	CharmURL  *charm.URL
	Origin    Origin
	Macaroons macaroon.Slice
}

MetadataRequest encapsulates the arguments for a charm essential metadata resolution request.

type Origin

type Origin struct {
	Source Source
	Type   string
	ID     string
	Hash   string

	// Users can request a revision to be installed instead of a channel, so
	// we should model that correctly here.
	Revision *int
	Channel  *charm.Channel
	Platform Platform

	// InstanceKey is a unique string associated with the application. To
	// assist with keeping KPI data in charmhub, it must be the same for every
	// charmhub Refresh action related to an application. Create with the
	// charmhub.CreateInstanceKey method. LP: 1944582
	InstanceKey string
}

Origin holds the original source of a charm. Information about where the charm was installed from (charm-hub, charm-store, local) and any additional information we can utilise when making modelling decisions for upgrading or changing.

type Platform

type Platform struct {
	Architecture string
	OS           string
	Series       string
}

Platform describes the platform used to install the charm with.

func MakePlatform

func MakePlatform(arch, os, series string) (Platform, error)

MakePlatform creates a core charm Platform from a set of component parts.

func MustParsePlatform

func MustParsePlatform(s string) Platform

MustParsePlatform parses a given string or returns a panic.

func ParsePlatform

func ParsePlatform(s string) (Platform, error)

ParsePlatform parses a string representing a store platform. Serialized version of platform can be expected to conform to the following:

  1. Architecture is mandatory.
  2. OS is optional and can be dropped. Release is mandatory if OS wants to be displayed.
  3. Release is also optional.

To indicate something is missing `unknown` can be used in place.

Examples:

  1. `<arch>/<os>/<series>`
  2. `<arch>`
  3. `<arch>/<series>`
  4. `<arch>/unknown/<series>`

func ParsePlatformNormalize

func ParsePlatformNormalize(s string) (Platform, error)

ParsePlatformNormalize parses a string presenting a store platform. The returned platform's architecture, os and series are normalized.

func (Platform) Normalize

func (p Platform) Normalize() Platform

Normalize the platform with normalized architecture, os and series.

func (Platform) String

func (p Platform) String() string

type Repository

type Repository interface {
	// GetDownloadURL returns a url from which a charm can be downloaded
	// based on the given charm url and charm origin.  A charm origin
	// updated with the ID and hash for the download is also returned.
	GetDownloadURL(*charm.URL, Origin, macaroon.Slice) (*url.URL, Origin, error)

	// DownloadCharm retrieves specified charm from the store and saves its
	// contents to the specified path.
	DownloadCharm(charmURL *charm.URL, requestedOrigin Origin, macaroons macaroon.Slice, archivePath string) (CharmArchive, Origin, error)

	// ResolveWithPreferredChannel verified that the charm with the requested
	// channel exists.  If no channel is specified, the latests, most stable is
	// is used. It returns a charm URL which includes the most current revision,
	// if none was provided, a charm origin, and a slice of series supported by
	// this charm.
	ResolveWithPreferredChannel(*charm.URL, Origin, macaroon.Slice) (*charm.URL, Origin, []string, error)

	// GetEssentialMetadata resolves each provided MetadataRequest and
	// returns back a slice with the results. The results include the
	// minimum set of metadata that is required for deploying each charm.
	GetEssentialMetadata(...MetadataRequest) ([]EssentialMetadata, error)

	// ListResources returns a list of resources associated with a given charm.
	ListResources(*charm.URL, Origin, macaroon.Slice) ([]charmresource.Resource, error)
}

Repository describes an API for querying charm/bundle information and downloading them from a store.

type RepositoryFactory

type RepositoryFactory interface {
	GetCharmRepository(src Source) (Repository, error)
}

RepositoryFactory is a factory for charm Repositories.

type Source

type Source string

Source represents the source of the charm.

const (
	// Local represents a local charm.
	Local Source = "local"
	// CharmStore represents a charm from the now old charmstore.
	CharmStore Source = "charm-store"
	// CharmHub represents a charm from the new charmHub.
	CharmHub Source = "charm-hub"
)

func (Source) Matches

func (c Source) Matches(o string) bool

Matches attempts to match a string to a given source.

func (Source) String

func (c Source) String() string

Directories

Path Synopsis
Package downloader is a generated GoMock package.
Package downloader is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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