charm

package
v0.0.0-...-f19ae85 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2015 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConflict = errors.New("charm upgrade has conflicts")

ErrConflict indicates that an upgrade failed and cannot be resolved without human intervention.

View Source
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.

View Source
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

func ReadCharmURL(path string) (*charm.URL, error)

ReadCharmURL reads a charm identity file from the supplied path.

func WriteCharmURL

func WriteCharmURL(path string, url *charm.URL) error

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 NewGitDir

func NewGitDir(path string) *GitDir

NewGitDir creates a new GitDir at path. It does not touch the filesystem.

func (*GitDir) AddAll

func (d *GitDir) AddAll() error

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

func (d *GitDir) Clone(path string) (*GitDir, error)

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

func (d *GitDir) Commitf(format string, args ...interface{}) error

Commitf commits a new revision to the repository with the supplied message.

func (*GitDir) Conflicted

func (d *GitDir) Conflicted() (bool, error)

Conflicted returns true if the directory contains any conflicts.

func (*GitDir) Dirty

func (d *GitDir) Dirty() (bool, error)

Dirty returns true if the directory contains any uncommitted local changes.

func (*GitDir) Exists

func (d *GitDir) Exists() (bool, error)

Exists returns true if the directory exists.

func (*GitDir) Init

func (d *GitDir) Init() error

Init ensures that a git repository exists in the directory.

func (*GitDir) Log

func (d *GitDir) Log() ([]string, error)

Log returns a highly compacted history of the directory.

func (*GitDir) Path

func (d *GitDir) Path() string

Path returns the directory path.

func (*GitDir) Pull

func (d *GitDir) Pull(src *GitDir) error

Pull pulls from the supplied GitDir.

func (*GitDir) ReadCharmURL

func (d *GitDir) ReadCharmURL() (*charm.URL, error)

ReadCharmURL reads the charm identity file from the GitDir.

func (*GitDir) Revert

func (d *GitDir) Revert() error

Revert removes unversioned files and reverts everything else to its state as of the most recent commit.

func (*GitDir) Snapshotf

func (d *GitDir) Snapshotf(format string, args ...interface{}) error

Snapshotf adds all changes made since the last commit, including deletions and empty directories, and commits them using the supplied message.

func (*GitDir) WriteCharmURL

func (d *GitDir) WriteCharmURL(url *charm.URL) error

WriteCharmURL writes the charm identity file into the GitDir.

Jump to

Keyboard shortcuts

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