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 IsKubernetes(cm charm.CharmMeta) bool
- func IsUnsupportedBaseError(err error) bool
- func MustParseChannel(s string) charm.Channel
- func NewCharmAtPath(path string) (charm.Charm, *charm.URL, error)
- func NewCharmInfoAdapter(meta EssentialMetadata) charmInfoAdapter
- func NewUnsupportedBaseError(requestedBase base.Base, supportedBases []base.Base) error
- func OSIsCompatibleWithCharm(os string, c charm.CharmMeta) error
- type BaseSelector
- type CharmArchive
- type CharmID
- type EssentialMetadata
- type MetadataFormat
- type MetadataRequest
- type Origin
- type Platform
- type Repository
- type RepositoryFactory
- type ResolvedDataForDeploy
- type SelectorConfig
- type SelectorLogger
- 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 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 IsUnsupportedBaseError ¶
IsUnsupportedBaseError returns true if err is an UnsupportedSeriesError.
func MustParseChannel ¶
func MustParseChannel(s string) charm.Channel
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.
func NewCharmInfoAdapter ¶
func NewCharmInfoAdapter(meta EssentialMetadata) charmInfoAdapter
func NewUnsupportedBaseError ¶
NewUnsupportedBaseError returns an error indicating that the requested series is not supported by a charm.
func OSIsCompatibleWithCharm ¶
OSIsCompatibleWithCharm returns nil is any of the bases the charm supports has an os which matched the provided os. Otherwise, return a NotSupported error
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 // Metadata is optional extra information about a particular model's // "in-theatre" use of the charm. Metadata map[string]string }
CharmID encapsulates data for identifying a unique charm in a charm repository.
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 ¶
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, charm-store, 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.
To indicate something is missing `unknown` can be used in place.
Examples:
- `<arch>/<os>/<channel>`
- `<arch>`
- `<arch>/<series>`
- `<arch>/unknown/<series>`
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(string, Origin) (*url.URL, Origin, error) // DownloadCharm retrieves specified charm from the store and saves its // contents to the specified path. DownloadCharm(charmName string, requestedOrigin Origin, 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 // 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(string, Origin) (*charm.URL, Origin, []Platform, 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(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(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(CharmID) (ResolvedDataForDeploy, 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 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 SelectorLogger 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 }
type SelectorLogger ¶
SelectorLogger defines the logging methods needed