charm

package
v0.0.0-...-6dcaeb9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const CharmURLPath = ".juju-charm"

CharmURLPath is the path within a charm directory to which Deployers commonly write the charm URL of the latest deployed charm.

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 NewDeployer = newDeployer

NewDeployer returns a manifest deployer. It is a var so that it can be patched for uniter tests.

Functions

func ClearDownloads

func ClearDownloads(bundlesDir string) error

ClearDownloads removes any entries in the temporary bundle download directory. It is intended to be called on uniter startup.

func ReadCharmURL

func ReadCharmURL(path string) (string, error)

ReadCharmURL reads a charm identity file from the supplied path.

func WriteCharmURL

func WriteCharmURL(path string, url string) error

WriteCharmURL writes a charm identity file into the supplied path.

Types

type Bundle

type Bundle interface {

	// ArchiveMembers returns a set of slash-separated strings representing files,
	// directories, and symlinks stored in the bundle.
	ArchiveMembers() (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 return the charm URL as a string.
	URL() string

	// 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, dlr Downloader, logger Logger) *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
}

Deployer is responsible for installing and upgrading charms.

func NewManifestDeployer

func NewManifestDeployer(charmPath, dataPath string, bundles BundleReader, logger Logger) 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 Downloader

type Downloader interface {
	// Download starts a new charm archive download, waits for it to
	// complete, and returns the local name of the file.
	Download(req downloader.Request) (string, error)
}

Download exposes the downloader.Download methods needed here.

type Logger

type Logger interface {
	Errorf(string, ...interface{})
	Warningf(string, ...interface{})
	Infof(string, ...interface{})
	Debugf(string, ...interface{})
}

Logger represents the logging functions used by the charm package.

type NewDeployerFunc

type NewDeployerFunc func(charmPath, dataPath string, bundles BundleReader, logger Logger) (Deployer, error)

NewDeployerFunc returns a func used to create a deployer.

type RetryingBundleReader

type RetryingBundleReader struct {
	BundleReader

	Clock  clock.Clock
	Logger Logger
}

func (RetryingBundleReader) Read

func (rbr RetryingBundleReader) Read(bi BundleInfo, abort <-chan struct{}) (Bundle, error)

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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