Documentation ¶
Index ¶
- Variables
- func ReadCharmURL(path string) (*charm.URL, error)
- func WriteCharmURL(path string, url *charm.URL) error
- type Bundle
- type BundleInfo
- type BundleReader
- type BundlesDir
- type Deployer
- type GitDir
- func (d *GitDir) AddAll() error
- func (d *GitDir) Clone(path string) (*GitDir, error)
- func (d *GitDir) Commitf(format string, args ...interface{}) error
- func (d *GitDir) Conflicted() (bool, error)
- func (d *GitDir) Dirty() (bool, error)
- func (d *GitDir) Exists() (bool, error)
- func (d *GitDir) Init() error
- func (d *GitDir) Log() ([]string, error)
- func (d *GitDir) Path() string
- func (d *GitDir) Pull(src *GitDir) error
- func (d *GitDir) ReadCharmURL() (*charm.URL, error)
- func (d *GitDir) Revert() error
- func (d *GitDir) Snapshotf(format string, args ...interface{}) error
- func (d *GitDir) WriteCharmURL(url *charm.URL) error
Constants ¶
This section is empty.
Variables ¶
var ErrConflict = errors.New("charm upgrade has conflicts")
ErrConflict indicates that an upgrade failed and cannot be resolved without human intervention.
var FixDeployer = fixDeployer
FixDeployer ensures that the supplied Deployer address points to a manifest deployer. If a git deployer is passed into FixDeployer, it will be converted to a manifest deployer, and the git deployer data will be removed. The charm is assumed to be in a stable state; this should not be called if there is any chance the git deployer is partway through an upgrade, or in a conflicted state. It is a var so that it can be patched for uniter tests.
var NewDeployer = newDeployer
NewDeployer returns a Deployer of whatever kind is currently in use for the supplied paths, or a manifest deployer if none exists yet. It is a var so that it can be patched for uniter tests.
Functions ¶
func ReadCharmURL ¶
ReadCharmURL reads a charm identity file from the supplied path.
func WriteCharmURL ¶
WriteCharmURL writes a charm identity file into the supplied path.
Types ¶
type Bundle ¶
type Bundle interface { // Manifest returns a set of slash-separated strings representing files, // directories, and symlinks stored in the bundle. Manifest() (set.Strings, error) // ExpandTo unpacks the entities referenced in the manifest into the // supplied directory. If it returns without error, every file referenced // in the charm must be present in the directory; implementations may vary // in the details of what they do with other files present. ExpandTo(dir string) error }
Bundle allows access to a charm's files.
type BundleInfo ¶
type BundleInfo interface { // URL returns the charm URL identifying the bundle. URL() *charm.URL // ArchiveURLs returns the location(s) of the bundle data. ArchiveURLs // may return multiple URLs; each should be tried until one succeeds. ArchiveURLs() ([]*url.URL, error) // ArchiveSha256 returns the hex-encoded SHA-256 digest of the bundle data. ArchiveSha256() (string, error) }
BundleInfo describes a Bundle.
type BundleReader ¶
type BundleReader interface { // Read returns the bundle identified by the supplied info. The abort chan // can be used to notify an implementation that it need not complete the // operation, and can immediately error out if it is convenient to do so. Read(bi BundleInfo, abort <-chan struct{}) (Bundle, error) }
BundleReader provides a mechanism for getting a Bundle from a BundleInfo.
type BundlesDir ¶
type BundlesDir struct {
// contains filtered or unexported fields
}
BundlesDir is responsible for storing and retrieving charm bundles identified by state charms.
func NewBundlesDir ¶
func NewBundlesDir(path string) *BundlesDir
NewBundlesDir returns a new BundlesDir which uses path for storage.
func (*BundlesDir) Read ¶
func (d *BundlesDir) Read(info BundleInfo, abort <-chan struct{}) (Bundle, error)
Read returns a charm bundle from the directory. If no bundle exists yet, one will be downloaded and validated and copied into the directory before being returned. Downloads will be aborted if a value is received on abort.
type Deployer ¶
type Deployer interface { // Stage must be called to prime the Deployer to install or upgrade the // bundle identified by the supplied info. The abort chan can be used to // notify an implementation that it need not complete the operation, and // can immediately error out if it convenient to do so. It must always // be safe to restage the same bundle, or to stage a new bundle. Stage(info BundleInfo, abort <-chan struct{}) error // Deploy will install or upgrade the most recently staged bundle. // Behaviour is undefined if Stage has not been called. Failures that // can be resolved by user intervention will be signalled by returning // ErrConflict. Deploy() error // NotifyRevert must be called when a conflicted deploy is abandoned, in // preparation for a new upgrade. NotifyRevert() error // NotifyResolved must be called when the cause of a deploy conflict has // been resolved, and a new deploy attempt will be made. NotifyResolved() error }
Deployer is responsible for installing and upgrading charms.
func NewGitDeployer ¶
func NewGitDeployer(charmPath, dataPath string, bundles BundleReader) Deployer
NewGitDeployer creates a new Deployer which stores its state in dataPath, and installs or upgrades the charm at charmPath.
func NewManifestDeployer ¶
func NewManifestDeployer(charmPath, dataPath string, bundles BundleReader) Deployer
NewManifestDeployer returns a Deployer that installs bundles from the supplied BundleReader into charmPath, and which reads and writes its persistent data into dataPath.
It works by always writing the full contents of a deployed charm; and, if another charm was previously deployed, deleting only those files unique to that base charm. It thus leaves user files in place, with the exception of those in directories referenced only in the original charm, which will be deleted.
type GitDir ¶
type GitDir struct {
// contains filtered or unexported fields
}
GitDir exposes a specialized subset of git operations on a directory.
func (*GitDir) AddAll ¶
AddAll ensures that the next commit will reflect the current contents of the directory. Empty directories will be preserved by inserting and tracking empty files named .empty.
func (*GitDir) Clone ¶
Clone creates a new GitDir at the specified path, with history cloned from the existing GitDir. It does not check out any files.
func (*GitDir) Commitf ¶
Commitf commits a new revision to the repository with the supplied message.
func (*GitDir) Conflicted ¶
Conflicted returns true if the directory contains any conflicts.
func (*GitDir) ReadCharmURL ¶
ReadCharmURL reads the charm identity file from the GitDir.
func (*GitDir) Revert ¶
Revert removes unversioned files and reverts everything else to its state as of the most recent commit.
func (*GitDir) Snapshotf ¶
Snapshotf adds all changes made since the last commit, including deletions and empty directories, and commits them using the supplied message.
func (*GitDir) WriteCharmURL ¶
WriteCharmURL writes the charm identity file into the GitDir.