Documentation ¶
Index ¶
- Constants
- Variables
- func BaseForCharm(requestedBase base.Base, supportedBases []base.Base) (base.Base, error)
- func BaseIsCompatibleWithCharm(b base.Base, c charm.CharmMeta) error
- func CharmNotFound(url string) error
- func ComputedBases(c charm.CharmMeta) ([]base.Base, error)
- func InvalidPath(path string) error
- func IsInvalidPathError(err error) bool
- func IsUnsupportedBaseError(err error) bool
- func MustParseChannel(s string) charm.Channel
- func NewCharmAtPath(path string) (charm.Charm, *charm.URL, error)
- func NewCharmInfoAdaptor(meta EssentialMetadata) charmInfoAdaptor
- func NewUnsupportedBaseError(requestedBase base.Base, supportedBases []base.Base) error
- func OSIsCompatibleWithCharm(os string, c charm.CharmMeta) error
- type BaseSelector
- type CharmArchive
- type CharmID
- type DownloadInfo
- type EssentialMetadata
- type ID
- type MetadataRequest
- type Origin
- type Platform
- type Repository
- type RepositoryFactory
- type ResolvedData
- type ResolvedDataForDeploy
- type SelectorConfig
- type SelectorModelConfig
- type Source
Constants ¶
const ( // DefaultChannelString represents the default track and risk if nothing // is found. DefaultChannelString = "stable" )
Variables ¶
var ( // DefaultChannel represents the default track and risk. DefaultChannel = charm.Channel{ Risk: charm.Stable, } // DefaultRiskChannel represents the default only risk channel. DefaultRiskChannel = charm.Channel{ Risk: charm.Stable, } )
var MissingBaseError = errors.ConstError("charm does not define any bases")
MissingBaseError is used to denote that BaseForCharm could not determine a base because a legacy charm did not declare any.
Functions ¶
func BaseForCharm ¶
BaseForCharm takes a requested base and a list of bases supported by a charm and returns the base which is relevant. If the requested base is empty, then the first supported base is used, otherwise the requested base is validated against the supported bases.
func BaseIsCompatibleWithCharm ¶
BaseIsCompatibleWithCharm returns nil if the provided charm is compatible with the provided base. Otherwise, return an UnsupportedBaseError
func CharmNotFound ¶
CharmNotFound returns an error indicating that the charm at the specified URL does not exist.
func ComputedBases ¶
ComputedBases of a charm, preserving legacy behaviour. For charms prior to v2, fall back the metadata series can convert to bases
func IsInvalidPathError ¶
func IsUnsupportedBaseError ¶
IsUnsupportedBaseError returns true if err is an UnsupportedSeriesError.
func MustParseChannel ¶
MustParseChannel parses a given string or returns a panic.
func NewCharmAtPath ¶
NewCharmAtPath returns the charm represented by this path, and a URL that describes it. Deploying from a directory is no longer supported.
func NewCharmInfoAdaptor ¶
func NewCharmInfoAdaptor(meta EssentialMetadata) charmInfoAdaptor
func NewUnsupportedBaseError ¶
NewUnsupportedBaseError returns an error indicating that the requested series is not supported by a charm.
Types ¶
type BaseSelector ¶
type BaseSelector struct {
// contains filtered or unexported fields
}
BaseSelector is a helper type that determines what base the charm should be deployed to.
func ConfigureBaseSelector ¶
func ConfigureBaseSelector(cfg SelectorConfig) (BaseSelector, error)
ConfigureBaseSelector returns a configured and validated BaseSelector
func (BaseSelector) CharmBase ¶
func (s BaseSelector) CharmBase() (selectedBase base.Base, err error)
CharmBase determines what base to use with a charm. Order of preference is:
- user requested with --base or defined by bundle when deploying
- model default, if set, acts like --base
- juju's default supported Ubuntu LTS (if compatible with valid charm bases)
- the first supported base in the charm manifest
- in the case of local charms with no manifest nor base in metadata, base must be provided by the user.
type CharmArchive ¶
type CharmArchive interface { charm.Charm Version() string LXDProfile() *charm.LXDProfile }
CharmArchive provides information about a downloaded charm archive.
type CharmID ¶
type CharmID struct { // URL is the url of the charm. URL *charm.URL // Origin holds the original source of a charm, including its channel. Origin Origin }
CharmID encapsulates data for identifying a unique charm in a charm repository.
type DownloadInfo ¶
type DownloadInfo struct { // CharmHubIdentifier is the identifier used to download the charm from // the charm store without referring to the name of the charm. CharmhubIdentifier string // DownloadURL is the URL to download the charm from the charm store. DownloadURL string // DownloadSize is the size of the charm to be downloaded. DownloadSize int64 }
DownloadInfo contains the information needed to download a charm from the charm store.
type EssentialMetadata ¶
type EssentialMetadata struct { ResolvedOrigin Origin Meta *charm.Meta Manifest *charm.Manifest Config *charm.Config // DownloadInfo is the information needed to download the charm // directly from the charm store. // This should always be present if the charm is being downloaded from // charmhub. DownloadInfo DownloadInfo }
EssentialMetadata encapsulates the essential metadata required for deploying a particular charm.
type ID ¶
type ID string
ID represents a charm unique identifier.
func ParseID ¶
ParseID returns a new ID from the given string. If the string is not a valid uuid an error satisfying errors.NotValid will be returned.
func (ID) Validate ¶
Validate ensures the consistency of the ID. If the uuid is invalid an error satisfying errors.NotValid will be returned.
type MetadataRequest ¶
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 an optional unique string associated with the application. // To assist with keeping KPI data in charmhub, it must be the same for every // charmhub Refresh action for the Refresh api endpoint related to an // application. For all other actions, a random uuid will used when the request // is sent. 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, local) and any additional information we can utilise when making modelling decisions for upgrading or changing.
type Platform ¶
Platform describes the platform used to install the charm with.
func MustParsePlatform ¶
MustParsePlatform parses a given string or returns a panic.
func ParsePlatform ¶
ParsePlatform parses a string representing a store platform. Serialized version of platform can be expected to conform to the following:
- Architecture is mandatory.
- OS is optional and can be dropped. Release is mandatory if OS wants to be displayed.
- Release is also optional. Release can also optionally include a risk
Examples:
- `<arch>/<os>/<channel>`
- `<arch>/<os>/<track>/<risk>`
- `<arch>`
func ParsePlatformNormalize ¶
ParsePlatformNormalize parses a string presenting a store platform. The returned platform's architecture, os and series are normalized.
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(context.Context, string, Origin) (*url.URL, Origin, error) // Download retrieves specified charm from the store and saves its // contents to the specified path. Download(ctx context.Context, name string, origin Origin, path string) (Origin, *charmhub.Digest, error) // DownloadCharm retrieves specified charm from the store and saves its // contents to the specified path. // Deprecated: use Download instead. DownloadCharm(ctx context.Context, charmName string, requestedOrigin Origin, archivePath string) (CharmArchive, Origin, *charmhub.Digest, error) // ResolveWithPreferredChannel verified that the charm with the requested // channel exists. If no channel is specified, the latests, most stable 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(context.Context, string, Origin) (ResolvedData, error) // ListResources returns a list of resources associated with a given charm. ListResources(context.Context, string, Origin) ([]charmresource.Resource, error) // ResolveResources looks at the provided repository and backend (already // downloaded) resources to determine which to use. Provided (uploaded) take // precedence. If charmhub has a newer resource than the back end, use that. ResolveResources(ctx context.Context, resources []charmresource.Resource, id CharmID) ([]charmresource.Resource, error) // ResolveForDeploy does the same thing as ResolveWithPreferredChannel // returning EssentialMetadata also. Resources are returned if a // charm revision was not provided in the CharmID. ResolveForDeploy(context.Context, CharmID) (ResolvedDataForDeploy, error) }
Repository describes an API for querying charm/bundle information and downloading them from a store.
type RepositoryFactory ¶
type RepositoryFactory interface {
GetCharmRepository(ctx context.Context, src Source) (Repository, error)
}
RepositoryFactory is a factory for charm Repositories.
type ResolvedData ¶
type ResolvedData struct { // URL is the url of the charm. URL *charm.URL // EssentialMetadata is the essential metadata required for deploying // the charm. EssentialMetadata EssentialMetadata // Origin holds the original source of a charm, including its channel. Origin Origin // Platform is the list of platforms supported by the charm. Platform []Platform }
ResolvedData is the response data from ResolveWithPreferredChannel.
type ResolvedDataForDeploy ¶
type ResolvedDataForDeploy struct { URL *charm.URL EssentialMetadata EssentialMetadata // Resources is a map of resource names to their current repository revision // based on the supplied origin Resources map[string]charmresource.Resource }
ResolvedDataForDeploy is the response data from ResolveForDeploy
type SelectorConfig ¶
type SelectorConfig struct { Config SelectorModelConfig Force bool Logger logger.Logger RequestedBase base.Base SupportedCharmBases []base.Base WorkloadBases []base.Base // usingImageID is true when the user is using the image-id constraint // when deploying the charm. This is needed to validate that in that // case the user is also explicitly providing a base. UsingImageID bool }