charm

package
v0.0.0-...-a7271ac Latest Latest
Warning

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

Go to latest
Published: May 4, 2014 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func ReadCharmURL

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

ReadCharmURL reads the charm identity file from the supplied GitDir.

func WriteCharmURL

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

WriteCharmURL writes a charm identity file into the directory.

Types

type BundleInfo

type BundleInfo interface {
	URL() *charm.URL
	ArchiveURL() (*url.URL, bool, error)
	ArchiveSha256() (string, error)
}

BundleInfo holds bundle information for a charm.

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{}) (*charm.Bundle, error)
}

BundleReader primarily exists to make BundlesDir mockable.

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{}) (*charm.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.
	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.

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) 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) SetIdent

func (d *GitDir) SetIdent() error

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.

Jump to

Keyboard shortcuts

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