Documentation ¶
Index ¶
- Constants
- Variables
- func AlwaysMatchChecksum(string) bool
- type Channel
- func MakeChannel(track, risk, branch string) (Channel, error)
- func MakePermissiveChannel(track, risk, branch string) Channel
- func MakeRiskOnlyChannel(risk string) Channel
- func MustParseChannel(s string) Channel
- func ParseChannel(s string) (Channel, error)
- func ParseChannelNormalize(s string) (Channel, error)
- type ChecksumCheckFn
- type DownloadRepo
- type DownloadResult
- type JujuVersionValidator
- type Logger
- type Origin
- type Platform
- type Repository
- type Risk
- type Source
- type State
- type StateCharm
- type Store
- type StoreCharm
- type StoreCharmHub
- type StoreCharmStore
- type Strategy
Constants ¶
const ( // DefaultChannelString represents the default track and risk if nothing // is found. DefaultChannelString = "latest/stable" )
Variables ¶
var ( // DefaultChannel represents the default track and risk. DefaultChannel = Channel{ Track: "latest", Risk: Stable, } // DefaultRiskChannel represents the default only risk channel. DefaultRiskChannel = Channel{ Risk: Stable, } )
Risks is a list of the available channel risks.
Functions ¶
func AlwaysMatchChecksum ¶
AlwaysMatchChecksum will always return true and is an effective no-op.
Types ¶
type Channel ¶
Channel identifies and describes completely a store channel.
A channel consists of, and is subdivided by, tracks, risk-levels and branches:
- Tracks enable snap developers to publish multiple supported releases of their application under the same snap name.
- Risk-levels represent a progressive potential trade-off between stability and new features.
- Branches are _optional_ and hold temporary releases intended to help with bug-fixing.
The complete channel name can be structured as three distinct parts separated by slashes:
<track>/<risk>/<branch>
func MakeChannel ¶
MakeChannel creates a core charm Channel from a set of component parts.
func MakePermissiveChannel ¶
MakePermissiveChannel creates a normalized core charm channel which never fails. It assumes that the risk has been prechecked.
func MakeRiskOnlyChannel ¶
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 ¶
MustParseChannel parses a given string or returns a panic.
func ParseChannel ¶
ParseChannel parses a string representing a store channel.
func ParseChannelNormalize ¶
ParseChannelNormalize parses a string representing a store channel. The returned channel's track, risk and name are normalized.
type ChecksumCheckFn ¶
ChecksumCheckFn defines a function for running checksums against.
func MatchChecksum ¶
func MatchChecksum(hash string) ChecksumCheckFn
MatchChecksum validates a checksum against another checksum.
type DownloadRepo ¶
type DownloadRepo interface { DownloadCharm(resourceURL, archivePath string) (*charm.CharmArchive, error) FindDownloadURL(*charm.URL, Origin) (*url.URL, Origin, error) }
DownloadRepo defines methods required for the repo to download a charm.
type DownloadResult ¶
type DownloadResult struct { // Charm is the metadata about the charm for the archive. Charm StoreCharm // Data contains the bytes of the archive. Data io.Reader // Size is the number of bytes in Data. Size int64 // SHA256 is the hash of the bytes in Data. SHA256 string }
DownloadResult defines the result from the attempt to install a charm into state.
type JujuVersionValidator ¶
type JujuVersionValidator interface { // Check the version is valid for the given Juju version. Validate(*charm.Meta) error }
JujuVersionValidator validates the version of Juju against the charm meta data. The charm.Meta contains a MinJujuVersion and we can use that to check that for a valid charm.
type Logger ¶
type Logger interface { Tracef(string, ...interface{}) Debugf(string, ...interface{}) Errorf(string, ...interface{}) Warningf(string, ...interface{}) Child(name string) Logger }
Logger defines the logging methods that the package uses.
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 *Channel Platform Platform }
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 MakePlatform ¶
MakePlatform creates a core charm Platform from a set of component parts.
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>/<series>`
- `<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 { // FindDownloadURL 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. FindDownloadURL(*charm.URL, Origin) (*url.URL, Origin, error) // DownloadCharm reads the charm referenced the resource URL or downloads // into a file with the given path, which will be created if needed. // It is expected that the URL for charm store will be in the correct // form i.e that it parses to a charm.URL. DownloadCharm(resourceURL, archivePath string) (*charm.CharmArchive, 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) (*charm.URL, Origin, []string, error) // ListResources returns a list of resources associated with a given charm. ListResources(*charm.URL, Origin) ([]charmresource.Resource, error) }
Repository represents the necessary methods to resolve and download charms from a repository where they reside.
type Source ¶
type Source string
Source represents the source of the charm.
type State ¶
type State interface {
PrepareCharmUpload(*charm.URL) (StateCharm, error)
}
State defines the underlying state for handling charms.
type StateCharm ¶
type StateCharm interface {
IsUploaded() bool
}
StateCharm represents a stored charm from state.
type Store ¶
type Store interface { // Validate checks to ensure that the charm URL is valid for the store. Validate(*charm.URL) error // Download a charm from the store using the charm URL. Download(*charm.URL, string, Origin) (StoreCharm, ChecksumCheckFn, Origin, error) // DownloadOrigin returns an origin with the id and hash, without // downloading the charm. DownloadOrigin(curl *charm.URL, origin Origin) (Origin, error) }
Store defines the store for which the charm is being downloaded from.
type StoreCharm ¶
type StoreCharm interface {
charm.Charm
charm.LXDProfiler
Version() string
}
StoreCharm represents a store charm.
type StoreCharmHub ¶
type StoreCharmHub struct {
// contains filtered or unexported fields
}
StoreCharmHub defines a type for interacting with the charm hub.
func (StoreCharmHub) Download ¶
func (s StoreCharmHub) Download(curl *charm.URL, file string, origin Origin) (StoreCharm, ChecksumCheckFn, Origin, error)
Download the charm from the charm hub.
func (StoreCharmHub) DownloadOrigin ¶
func (s StoreCharmHub) DownloadOrigin(curl *charm.URL, origin Origin) (Origin, error)
DownloadOrigin returns an origin with the id and hash, without downloading the charm.
func (StoreCharmHub) Validate ¶
func (StoreCharmHub) Validate(curl *charm.URL) error
Validate checks to ensure that the schema is valid for the store.
type StoreCharmStore ¶
type StoreCharmStore struct {
// contains filtered or unexported fields
}
StoreCharmStore defines a type for interacting with the charm store.
func (StoreCharmStore) Download ¶
func (s StoreCharmStore) Download(curl *charm.URL, file string, origin Origin) (StoreCharm, ChecksumCheckFn, Origin, error)
Download the charm from the charm store.
func (StoreCharmStore) DownloadOrigin ¶
func (s StoreCharmStore) DownloadOrigin(_ *charm.URL, origin Origin) (Origin, error)
DownloadOrigin returns the same origin provided. This operation is required for CharmHub.
func (StoreCharmStore) Validate ¶
func (StoreCharmStore) Validate(curl *charm.URL) error
Validate checks to ensure that the schema is valid for the store.
type Strategy ¶
type Strategy struct {
// contains filtered or unexported fields
}
Strategy defines a procedure for adding a charm to state.
func DownloadFromCharmHub ¶
func DownloadFromCharmHub(logger loggo.Logger, repository DownloadRepo, curl string, force bool) (*Strategy, error)
DownloadFromCharmHub will creates a procedure to install a charm from the charm hub.
func DownloadFromCharmStore ¶
func DownloadFromCharmStore(logger loggo.Logger, repository DownloadRepo, url string, force bool) (*Strategy, error)
DownloadFromCharmStore will creates a procedure to install a charm from the charm store.
func (*Strategy) CharmURL ¶
func (p *Strategy) CharmURL() *charm.URL
CharmURL returns the strategy URL associated with it.
func (*Strategy) Finish ¶
Finish will attempt to close out the download procedure. Cleaning up any outstanding function tasks. If the function task errors out, then it prevents any further task from being executed. It is expected that each task correctly handles the error if they want to continue with finishing all the tasks.
func (*Strategy) Run ¶
func (p *Strategy) Run(state State, version JujuVersionValidator, origin Origin) (DownloadResult, bool, Origin, error)
Run the download procedure against the supplied store adapter. Includes downloading the blob to a temp file and validating the contents of the charm.Meta and LXD profile data.