charm

package module
v4.0.0-...-af4be7b Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2015 License: LGPL-3.0 Imports: 28 Imported by: 34

README

Juju charms

This package parses juju charms.

Versions

Stable versions of this API are available on gopkg.in at gopkg.in/juju/charm.vD where D is a version spec. If you are viewing this readme on github.com you can click the 'branch:' button above to view tags and branches. See http://labix.org/gopkg.in for more information.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheDir string

CacheDir stores the charm cache directory path.

View Source
var ErrUnresolvedUrl error = fmt.Errorf("charm url series is not resolved")
View Source
var Store = &CharmStore{BaseURL: "https://store.juju.ubuntu.com"}

Functions

func IsValidName

func IsValidName(name string) bool

IsValidName returns whether name is a valid charm name.

func IsValidSeries

func IsValidSeries(series string) bool

IsValidSeries returns whether series is a valid series in charm URLs.

func Latest

func Latest(repo Repository, curl *URL) (int, error)

Latest returns the latest revision of the charm referenced by curl, regardless of the revision set on each curl. This is a helper which calls the bulk method and unpacks a single result.

func Quote

func Quote(unsafe string) string

Quote translates a charm url string into one which can be safely used in a file path. ASCII letters, ASCII digits, dot and dash stay the same; other characters are translated to their hex representation surrounded by underscores.

Types

type ActionSpec

type ActionSpec struct {
	Description string
	Params      map[string]interface{}
}

ActionSpec is a definition of the parameters and traits of an Action. The Params map is expected to conform to JSON-Schema Draft 4 as defined at http://json-schema.org/draft-04/schema# (see http://json-schema.org/latest/json-schema-core.html)

func (*ActionSpec) InsertDefaults

func (spec *ActionSpec) InsertDefaults(target map[string]interface{}) (map[string]interface{}, error)

InsertDefaults inserts the schema's default values in target using github.com/juju/gojsonschema. If a nil target is received, an empty map will be created as the target. The target is then mutated to include the defaults.

The returned map will be the transformed or created target map.

func (*ActionSpec) ValidateParams

func (spec *ActionSpec) ValidateParams(params map[string]interface{}) error

ValidateParams validates the passed params map against the given ActionSpec and returns any error encountered. Usage:

err := ch.Actions().ActionSpecs["snapshot"].ValidateParams(someMap)

type Actions

type Actions struct {
	ActionSpecs map[string]ActionSpec `yaml:"actions,omitempty" bson:",omitempty"`
}

Actions defines the available actions for the charm. Additional params may be added as metadata at a future time (e.g. version.)

func NewActions

func NewActions() *Actions

Build this out further if it becomes necessary.

func ReadActionsYaml

func ReadActionsYaml(r io.Reader) (*Actions, error)

ReadActions builds an Actions spec from a charm's actions.yaml.

type Bundle

type Bundle interface {
	// Data returns the contents of the bundle's bundle.yaml file.
	Data() *BundleData
	// Data returns the contents of the bundle's README.md file.
	ReadMe() string
}

The Bundle interface is implemented by any type that may be handled as a bundle. It encapsulates all the data of a bundle.

func ReadBundle

func ReadBundle(path string) (Bundle, error)

ReadBundle reads a Bundle from path, which can point to either a bundle archive or a bundle directory.

type BundleArchive

type BundleArchive struct {
	Path string
	// contains filtered or unexported fields
}

func ReadBundleArchive

func ReadBundleArchive(path string) (*BundleArchive, error)

ReadBundleArchive reads a bundle archive from the given file path.

func ReadBundleArchiveBytes

func ReadBundleArchiveBytes(data []byte) (*BundleArchive, error)

ReadBundleArchiveBytes reads a bundle archive from the given byte slice.

func ReadBundleArchiveFromReader

func ReadBundleArchiveFromReader(r io.ReaderAt, size int64) (*BundleArchive, error)

ReadBundleArchiveFromReader returns a BundleArchive that uses r to read the bundle. The given size must hold the number of available bytes in the file.

Note that the caller is responsible for closing r - methods on the returned BundleArchive may fail after that.

func (*BundleArchive) Data

func (a *BundleArchive) Data() *BundleData

Data implements Bundle.Data.

func (*BundleArchive) ExpandTo

func (a *BundleArchive) ExpandTo(dir string) error

ExpandTo expands the bundle archive into dir, creating it if necessary. If any errors occur during the expansion procedure, the process will abort.

func (*BundleArchive) ReadMe

func (a *BundleArchive) ReadMe() string

ReadMe implements Bundle.ReadMe.

type BundleData

type BundleData struct {
	// Services holds one entry for each service
	// that the bundle will create, indexed by
	// the service name.
	Services map[string]*ServiceSpec

	// Machines holds one entry for each machine referred to
	// by unit placements. These will be mapped onto actual
	// machines at bundle deployment time.
	// It is an error if a machine is specified but
	// not referred to by a unit placement directive.
	Machines map[string]*MachineSpec `bson:",omitempty" json:",omitempty" yaml:",omitempty"`

	// Series holds the default series to use when
	// the bundle chooses charms.
	Series string `bson:",omitempty" json:",omitempty" yaml:",omitempty"`

	// Relations holds a slice of 2-element slices,
	// each specifying a relation between two services.
	// Each two-element slice holds two endpoints,
	// each specified as either colon-separated
	// (service, relation) pair or just a service name.
	// The relation is made between each. If the relation
	// name is omitted, it will be inferred from the available
	// relations defined in the services' charms.
	Relations [][]string `bson:",omitempty" json:",omitempty" yaml:",omitempty"`

	// White listed set of tags to categorize bundles as we do charms.
	Tags []string `bson:",omitempty" json:",omitempty" yaml:",omitempty"`

	// Short paragraph explaining what the bundle is useful for.
	Description string `bson:",omitempty" json:",omitempty" yaml:",omitempty"`
}

BundleData holds the contents of the bundle.

func ReadBundleData

func ReadBundleData(r io.Reader) (*BundleData, error)

ReadBundleData reads bundle data from the given reader. The returned data is not verified - call Verify to ensure that it is OK.

func (*BundleData) RequiredCharms

func (bd *BundleData) RequiredCharms() []string

RequiredCharms returns a sorted slice of all the charm URLs required by the bundle.

func (*BundleData) Verify

func (bd *BundleData) Verify(
	verifyConstraints func(c string) error,
) error

Verify is a convenience method that calls VerifyWithCharms with a nil charms map.

func (*BundleData) VerifyWithCharms

func (bd *BundleData) VerifyWithCharms(
	verifyConstraints func(c string) error,
	charms map[string]Charm,
) error

VerifyWithCharms verifies that the bundle is consistent. The verifyConstraints function is called to verify any constraints that are found. If verifyConstraints is nil, no checking of constraints will be done.

It verifies the following:

- All defined machines are referred to by placement directives. - All services referred to by placement directives are specified in the bundle. - All services referred to by relations are specified in the bundle. - All constraints are valid.

If charms is not nil, it should hold a map with an entry for each charm url returned by bd.RequiredCharms. The verification will then also check that services are defined with valid charms, relations are correctly made and options are defined correctly.

If the verification fails, Verify returns a *VerificationError describing all the problems found.

type BundleDir

type BundleDir struct {
	Path string
	// contains filtered or unexported fields
}

func ReadBundleDir

func ReadBundleDir(path string) (dir *BundleDir, err error)

ReadBundleDir returns a BundleDir representing an expanded bundle directory. It does not verify the bundle data.

func (*BundleDir) ArchiveTo

func (dir *BundleDir) ArchiveTo(w io.Writer) error

func (*BundleDir) Data

func (dir *BundleDir) Data() *BundleData

func (*BundleDir) ReadMe

func (dir *BundleDir) ReadMe() string

type Charm

type Charm interface {
	Meta() *Meta
	Config() *Config
	Metrics() *Metrics
	Actions() *Actions
	Revision() int
}

The Charm interface is implemented by any type that may be handled as a charm.

func ReadCharm

func ReadCharm(path string) (charm Charm, err error)

ReadCharm reads a Charm from path, which can point to either a charm archive or a charm directory.

type CharmArchive

type CharmArchive struct {
	Path string // May be empty if CharmArchive wasn't read from a file
	// contains filtered or unexported fields
}

The CharmArchive type encapsulates access to data and operations on a charm archive.

func ReadCharmArchive

func ReadCharmArchive(path string) (*CharmArchive, error)

ReadCharmArchive returns a CharmArchive for the charm in path.

func ReadCharmArchiveBytes

func ReadCharmArchiveBytes(data []byte) (archive *CharmArchive, err error)

ReadCharmArchiveBytes returns a CharmArchive read from the given data. Make sure the archive fits in memory before using this.

func ReadCharmArchiveFromReader

func ReadCharmArchiveFromReader(r io.ReaderAt, size int64) (archive *CharmArchive, err error)

ReadCharmArchiveFromReader returns a CharmArchive that uses r to read the charm. The given size must hold the number of available bytes in the file.

Note that the caller is responsible for closing r - methods on the returned CharmArchive may fail after that.

func (*CharmArchive) Actions

func (a *CharmArchive) Actions() *Actions

Actions returns the Actions map for the actions.yaml file for the charm archive.

func (*CharmArchive) Config

func (a *CharmArchive) Config() *Config

Config returns the Config representing the config.yaml file for the charm archive.

func (*CharmArchive) ExpandTo

func (a *CharmArchive) ExpandTo(dir string) error

ExpandTo expands the charm archive into dir, creating it if necessary. If any errors occur during the expansion procedure, the process will abort.

func (*CharmArchive) Manifest

func (a *CharmArchive) Manifest() (set.Strings, error)

Manifest returns a set of the charm's contents.

func (*CharmArchive) Meta

func (a *CharmArchive) Meta() *Meta

Meta returns the Meta representing the metadata.yaml file from archive.

func (*CharmArchive) Metrics

func (a *CharmArchive) Metrics() *Metrics

Metrics returns the Metrics representing the metrics.yaml file for the charm archive.

func (*CharmArchive) Revision

func (a *CharmArchive) Revision() int

Revision returns the revision number for the charm expanded in dir.

func (*CharmArchive) SetRevision

func (a *CharmArchive) SetRevision(revision int)

SetRevision changes the charm revision number. This affects the revision reported by Revision and the revision of the charm directory created by ExpandTo.

type CharmDir

type CharmDir struct {
	Path string
	// contains filtered or unexported fields
}

The CharmDir type encapsulates access to data and operations on a charm directory.

func ReadCharmDir

func ReadCharmDir(path string) (dir *CharmDir, err error)

ReadCharmDir returns a CharmDir representing an expanded charm directory.

func (*CharmDir) Actions

func (dir *CharmDir) Actions() *Actions

Actions returns the Actions representing the actions.yaml file for the charm expanded in dir.

func (*CharmDir) ArchiveTo

func (dir *CharmDir) ArchiveTo(w io.Writer) error

ArchiveTo creates a charm file from the charm expanded in dir. By convention a charm archive should have a ".charm" suffix.

func (*CharmDir) Config

func (dir *CharmDir) Config() *Config

Config returns the Config representing the config.yaml file for the charm expanded in dir.

func (*CharmDir) Meta

func (dir *CharmDir) Meta() *Meta

Meta returns the Meta representing the metadata.yaml file for the charm expanded in dir.

func (*CharmDir) Metrics

func (dir *CharmDir) Metrics() *Metrics

Metrics returns the Metrics representing the metrics.yaml file for the charm expanded in dir.

func (*CharmDir) Revision

func (dir *CharmDir) Revision() int

Revision returns the revision number for the charm expanded in dir.

func (*CharmDir) SetDiskRevision

func (dir *CharmDir) SetDiskRevision(revision int) error

SetDiskRevision does the same as SetRevision but also changes the revision file in the charm directory.

func (*CharmDir) SetRevision

func (dir *CharmDir) SetRevision(revision int)

SetRevision changes the charm revision number. This affects the revision reported by Revision and the revision of the charm archived by ArchiveTo. The revision file in the charm directory is not modified.

type CharmRevision

type CharmRevision struct {
	Revision int
	Sha256   string
	Err      error
}

CharmRevision holds the revision number of a charm and any error encountered in retrieving it.

type CharmStore

type CharmStore struct {
	BaseURL string
	// contains filtered or unexported fields
}

CharmStore is a Repository that provides access to the public juju charm store.

func (*CharmStore) BranchLocation

func (s *CharmStore) BranchLocation(curl *URL) string

BranchLocation returns the location for the branch holding the charm at curl.

func (*CharmStore) CharmURL

func (s *CharmStore) CharmURL(location string) (*URL, error)

CharmURL returns the charm URL for the branch at location.

func (*CharmStore) Event

func (s *CharmStore) Event(curl *URL, digest string) (*EventResponse, error)

Event returns details for a charm event in the charm store.

If digest is empty, the latest event is returned.

func (*CharmStore) Get

func (s *CharmStore) Get(curl *URL) (Charm, error)

Get returns the charm referenced by curl. CacheDir must have been set, otherwise Get will panic.

func (*CharmStore) Info

func (s *CharmStore) Info(curls ...Location) ([]*InfoResponse, error)

Info returns details for all the specified charms in the charm store.

func (*CharmStore) Latest

func (s *CharmStore) Latest(curls ...*URL) ([]CharmRevision, error)

Latest returns the latest revision of the charms referenced by curls, regardless of the revision set on each curl.

func (*CharmStore) Resolve

func (s *CharmStore) Resolve(ref *Reference) (*URL, error)

Resolve canonicalizes charm URLs any implied series in the reference.

func (*CharmStore) WithAuthAttrs

func (s *CharmStore) WithAuthAttrs(authAttrs string) Repository

WithAuthAttrs return a Repository with the authentication token list set. authAttrs is a list of attr=value pairs.

func (*CharmStore) WithJujuAttrs

func (s *CharmStore) WithJujuAttrs(jujuAttrs string) Repository

WithJujuAttrs returns a Repository with the Juju metadata attributes set. jujuAttrs is a list of attr=value pairs.

func (*CharmStore) WithTestMode

func (s *CharmStore) WithTestMode(testMode bool) Repository

WithTestMode returns a Repository where testMode is set to value passed to this method.

type Config

type Config struct {
	Options map[string]Option
}

Config represents the supported configuration options for a charm, as declared in its config.yaml file.

func NewConfig

func NewConfig() *Config

NewConfig returns a new Config without any options.

func ReadConfig

func ReadConfig(r io.Reader) (*Config, error)

ReadConfig reads a Config in YAML format.

func (*Config) DefaultSettings

func (c *Config) DefaultSettings() Settings

DefaultSettings returns settings containing the default value of every option in the config. Default values may be nil.

func (*Config) FilterSettings

func (c *Config) FilterSettings(settings Settings) Settings

FilterSettings returns the subset of the supplied settings that are valid.

func (*Config) ParseSettingsStrings

func (c *Config) ParseSettingsStrings(values map[string]string) (Settings, error)

ParseSettingsStrings returns settings derived from the supplied map. Every value in the map must be parseable to the correct type for the option identified by its key. Empty values are interpreted as nil.

func (*Config) ParseSettingsYAML

func (c *Config) ParseSettingsYAML(yamlData []byte, key string) (Settings, error)

ParseSettingsYAML returns settings derived from the supplied YAML data. The YAML must unmarshal to a map of strings to settings data; the supplied key must be present in the map, and must point to a map in which every value must have, or be a string parseable to, the correct type for the associated config option. Empty strings and nil values are both interpreted as nil.

func (*Config) ValidateSettings

func (c *Config) ValidateSettings(settings Settings) (Settings, error)

ValidateSettings returns a copy of the supplied settings with a consistent type for each value. It returns an error if the settings contain unknown keys or invalid values.

type EventResponse

type EventResponse struct {
	Kind     string   `json:"kind"`
	Revision int      `json:"revision"` // Zero is valid. Can't omitempty.
	Digest   string   `json:"digest,omitempty"`
	Errors   []string `json:"errors,omitempty"`
	Warnings []string `json:"warnings,omitempty"`
	Time     string   `json:"time,omitempty"`
}

EventResponse is sent by the charm store in response to charm-event requests.

type InfoResponse

type InfoResponse struct {
	CanonicalURL string   `json:"canonical-url,omitempty"`
	Revision     int      `json:"revision"` // Zero is valid. Can't omitempty.
	Sha256       string   `json:"sha256,omitempty"`
	Digest       string   `json:"digest,omitempty"`
	Errors       []string `json:"errors,omitempty"`
	Warnings     []string `json:"warnings,omitempty"`
}

InfoResponse is sent by the charm store in response to charm-info requests.

type LocalRepository

type LocalRepository struct {
	Path string
	// contains filtered or unexported fields
}

LocalRepository represents a local directory containing subdirectories named after an Ubuntu series, each of which contains charms targeted for that series. For example:

/path/to/repository/oneiric/mongodb/
/path/to/repository/precise/mongodb.charm
/path/to/repository/precise/wordpress/

func (*LocalRepository) Get

func (r *LocalRepository) Get(curl *URL) (Charm, error)

Get returns a charm matching curl, if one exists. If curl has a revision of -1, it returns the latest charm that matches curl. If multiple candidates satisfy the foregoing, the first one encountered will be returned.

func (*LocalRepository) Latest

func (r *LocalRepository) Latest(curls ...*URL) ([]CharmRevision, error)

Latest returns the latest revision of the charm referenced by curl, regardless of the revision set on curl itself.

func (*LocalRepository) Resolve

func (r *LocalRepository) Resolve(ref *Reference) (*URL, error)

Resolve canonicalizes charm URLs, resolving references and implied series.

func (*LocalRepository) WithDefaultSeries

func (r *LocalRepository) WithDefaultSeries(defaultSeries string) Repository

WithDefaultSeries returns a Repository with the default series set.

type Location

type Location interface {
	Path() string
	String() string
}

Location represents a charm location, which must declare a path component and a string representaion.

type MachineSpec

type MachineSpec struct {
	Constraints string            `bson:",omitempty" json:",omitempty" yaml:",omitempty"`
	Annotations map[string]string `bson:",omitempty" json:",omitempty" yaml:",omitempty"`
}

MachineSpec represents a notional machine that will be mapped onto an actual machine at bundle deployment time.

type Meta

type Meta struct {
	Name        string              `bson:"name"`
	Summary     string              `bson:"summary"`
	Description string              `bson:"description"`
	Subordinate bool                `bson:"subordinate"`
	Provides    map[string]Relation `bson:"provides,omitempty"`
	Requires    map[string]Relation `bson:"requires,omitempty"`
	Peers       map[string]Relation `bson:"peers,omitempty"`
	Format      int                 `bson:"format,omitempty"`
	OldRevision int                 `bson:"oldrevision,omitempty"` // Obsolete
	Categories  []string            `bson:"categories,omitempty"`
	Tags        []string            `bson:"tags,omitempty"`
	Series      string              `bson:"series,omitempty"`
	Storage     map[string]Storage  `bson:"storage,omitempty"`
}

Meta represents all the known content that may be defined within a charm's metadata.yaml file.

func ReadMeta

func ReadMeta(r io.Reader) (meta *Meta, err error)

ReadMeta reads the content of a metadata.yaml file and returns its representation.

func (Meta) Check

func (meta Meta) Check() error

Check checks that the metadata is well-formed.

func (Meta) GetYAML

func (m Meta) GetYAML() (tag string, value interface{})

GetYAML implements yaml.Getter.GetYAML.

func (Meta) Hooks

func (m Meta) Hooks() map[string]bool

Hooks returns a map of all possible valid hooks, taking relations into account. It's a map to enable fast lookups, and the value is always true.

type Metric

type Metric struct {
	Type        MetricType
	Description string
}

Metric represents a single metric definition

type MetricType

type MetricType string

MetricType is used to identify metric types supported by juju.

const (
	// Supported metric types.
	MetricTypeGauge    MetricType = "gauge"
	MetricTypeAbsolute MetricType = "absolute"
)

type Metrics

type Metrics struct {
	Metrics map[string]Metric
}

Metrics contains the metrics declarations encoded in the metrics.yaml file.

func ReadMetrics

func ReadMetrics(r io.Reader) (*Metrics, error)

ReadMetrics reads a MetricsDeclaration in YAML format.

func (Metrics) ValidateMetric

func (m Metrics) ValidateMetric(name, value string) error

ValidateMetric validates the supplied metric name and value against the loaded metric definitions.

type NotFoundError

type NotFoundError struct {
	// contains filtered or unexported fields
}

NotFoundError represents an error indicating that the requested data wasn't found.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Option

type Option struct {
	Type        string      `yaml:"type"`
	Description string      `yaml:"description,omitempty"`
	Default     interface{} `yaml:"default,omitempty"`
}

Option represents a single charm config option.

type Reference

type Reference URL

Reference represents a charm location with a series that may be unresolved.

cs:~joe/wordpress
cs:wordpress-42
cs:precise/wordpress

func MustParseReference

func MustParseReference(url string) *Reference

MustParseReference works like ParseReference, but panics in case of errors.

func ParseReference

func ParseReference(url string) (*Reference, error)

ParseReference returns a charm reference inferred from src. The provided src may be a valid URL or it may be an alias in one of the following formats:

name
name-revision
series/name
series/name-revision
schema:name
schema:name-revision
schema:~user/name
schema:~user/name-revision

A missing schema is assumed to be 'cs'.

func (*Reference) GetBSON

func (r *Reference) GetBSON() (interface{}, error)

GetBSON turns r into a bson.Getter so it can be saved directly on a MongoDB database with mgo.

func (*Reference) MarshalJSON

func (r *Reference) MarshalJSON() ([]byte, error)

func (Reference) Path

func (r Reference) Path() string

func (*Reference) SetBSON

func (r *Reference) SetBSON(raw bson.Raw) error

SetBSON turns u into a bson.Setter so it can be loaded directly from a MongoDB database with mgo.

func (Reference) String

func (r Reference) String() string

func (*Reference) URL

func (ref *Reference) URL(defaultSeries string) (*URL, error)

URL returns a full URL from the reference, creating a new URL value if necessary with the given default series. It returns an error if ref does not specify a series and defaultSeries is empty.

func (*Reference) UnmarshalJSON

func (r *Reference) UnmarshalJSON(b []byte) error

type Relation

type Relation struct {
	Name      string        `bson:"name"`
	Role      RelationRole  `bson:"role"`
	Interface string        `bson:"interface"`
	Optional  bool          `bson:"optional"`
	Limit     int           `bson:"limit"`
	Scope     RelationScope `bson:"scope"`
}

Relation represents a single relation defined in the charm metadata.yaml file.

func (Relation) ImplementedBy

func (r Relation) ImplementedBy(ch Charm) bool

ImplementedBy returns whether the relation is implemented by the supplied charm.

func (Relation) IsImplicit

func (r Relation) IsImplicit() bool

IsImplicit returns whether the relation is supplied by juju itself, rather than by a charm.

type RelationRole

type RelationRole string

RelationRole defines the role of a relation.

const (
	RoleProvider RelationRole = "provider"
	RoleRequirer RelationRole = "requirer"
	RolePeer     RelationRole = "peer"
)

type RelationScope

type RelationScope string

RelationScope describes the scope of a relation.

const (
	ScopeGlobal    RelationScope = "global"
	ScopeContainer RelationScope = "container"
)

type Repository

type Repository interface {
	Get(curl *URL) (Charm, error)
	Latest(curls ...*URL) ([]CharmRevision, error)
	Resolve(ref *Reference) (*URL, error)
}

Repository represents a collection of charms.

func InferRepository

func InferRepository(ref *Reference, localRepoPath string) (repo Repository, err error)

InferRepository returns a charm repository inferred from the provided charm or bundle reference. Local references will use the provided path.

type ServiceSpec

type ServiceSpec struct {
	// Charm holds the charm URL of the charm to
	// use for the given service.
	Charm string

	// NumUnits holds the number of units of the
	// service that will be deployed.
	NumUnits int `yaml:"num_units"`

	// To may hold up to NumUnits members with
	// each member specifying a desired placement
	// for the respective unit of the service.
	//
	// In regular-expression-like notation, each
	// element matches the following pattern:
	//
	//      (<containertype>:)?(<unit>|<machine>|new)
	//
	// If containertype is specified, the unit is deployed
	// into a new container of that type, otherwise
	// it will be "hulk-smashed" into the specified location,
	// by co-locating it with any other units that happen to
	// be there, which may result in unintended behavior.
	//
	// The second part (after the colon) specifies where
	// the new unit should be placed - it may refer to
	// a unit of another service specified in the bundle,
	// a machine id specified in the machines section,
	// or the special name "new" which specifies a newly
	// created machine.
	//
	// A unit placement may be specified with a service name only,
	// in which case its unit number is assumed to
	// be one more than the unit number of the previous
	// unit in the list with the same service, or zero
	// if there were none.
	//
	// If there are less elements in To than NumUnits,
	// the last element is replicated to fill it. If there
	// are no elements (or To is omitted), "new" is replicated.
	//
	// For example:
	//
	//     wordpress/0 wordpress/1 lxc:0 kvm:new
	//
	//  specifies that the first two units get hulk-smashed
	//  onto the first two units of the wordpress service,
	//  the third unit gets allocated onto an lxc container
	//  on machine 0, and subsequent units get allocated
	//  on kvm containers on new machines.
	//
	// The above example is the same as this:
	//
	//     wordpress wordpress lxc:0 kvm:new
	To []string `bson:",omitempty" json:",omitempty" yaml:",omitempty"`

	// Options holds the configuration values
	// to apply to the new service. They should
	// be compatible with the charm configuration.
	Options map[string]interface{} `bson:",omitempty" json:",omitempty" yaml:",omitempty"`

	// Annotations holds any annotations to apply to the
	// service when deployed.
	Annotations map[string]string `bson:",omitempty" json:",omitempty" yaml:",omitempty"`

	// Constraints holds the default constraints to apply
	// when creating new machines for units of the service.
	// This is ignored for units with explicit placement directives.
	Constraints string `bson:",omitempty" json:",omitempty" yaml:",omitempty"`
}

ServiceSpec represents a single service that will be deployed as part of the bundle.

type Settings

type Settings map[string]interface{}

Settings is a group of charm config option names and values. A Settings S is considered valid by the Config C if every key in S is an option in C, and every value either has the correct type or is nil.

type Storage

type Storage struct {
	// Name is the name of the store.
	//
	// Name has no default, and must be specified.
	Name string `bson:"name"`

	// Description is a description of the store.
	//
	// Description has no default, and is optional.
	Description string `bson:"description"`

	// Type is the storage type: filesystem or block-device.
	//
	// Type has no default, and must be specified.
	Type StorageType `bson:"type"`

	// Shared indicates that the storage is shared between all units of
	// a service deployed from the charm. It is an error to attempt to
	// assign non-shareable storage to a "shared" storage requirement.
	//
	// Shared defaults to false.
	Shared bool `bson:"shared"`

	// ReadOnly indicates that the storage should be made read-only if
	// possible. If the storage cannot be made read-only, Juju will warn
	// the user.
	//
	// ReadOnly defaults to false.
	ReadOnly bool `bson:"read-only"`

	// CountMin is the number of storage instances that must be attached
	// to the charm for it to be useful; the charm will not install until
	// this number has been satisfied. This must be a non-negative number.
	//
	// CountMin defaults to 1 for singleton stores.
	CountMin int `bson:"countmin"`

	// CountMax is the largest number of storage instances that can be
	// attached to the charm. If CountMax is -1, then there is no upper
	// bound.
	//
	// CountMax defaults to 1 for singleton stores.
	CountMax int `bson:"countmax"`

	// MinimumSize is the minimum size of store that the charm needs to
	// work at all. This is not a recommended size or a comfortable size
	// or a will-work-well size, just a bare minimum below which the charm
	// is going to break.
	// MinimumSize requires a unit, one of MGTPEZY, and is stored as MiB.
	//
	// There is no default MinimumSize; if left unspecified, a provider
	// specific default will be used, typically 1GB for block storage.
	MinimumSize uint64 `bson:"minimum-size"`

	// Location is the mount location for filesystem stores. For multi-
	// stores, the location acts as the parent directory for each mounted
	// store.
	//
	// Location has no default, and is optional.
	Location string `bson:"location,omitempty"`

	// Properties allow the charm author to characterise the relative storage
	// performance requirements and sensitivities for each store.
	// eg “transient” is used to indicate that non persistent storage is acceptable,
	// such as tmpfs or ephemeral instance disks.
	//
	// Properties has no default, and is optional.
	Properties []string `bson:properties,omitempty`
}

Storage represents a charm's storage requirement.

type StorageType

type StorageType string

StorageType defines a storage type.

const (
	StorageBlock      StorageType = "block"
	StorageFilesystem StorageType = "filesystem"
)

type URL

type URL struct {
	Schema   string // "cs" or "local"
	User     string // "joe"
	Name     string // "wordpress"
	Revision int    // -1 if unset, N otherwise
	Series   string
}

URL represents a fully resolved charm location with a specific series, such as:

cs:~joe/oneiric/wordpress
cs:oneiric/wordpress-42
local:oneiric/wordpress

func InferURL

func InferURL(src, defaultSeries string) (*URL, error)

InferURL parses src as a reference, fills out the series in the returned URL using defaultSeries if necessary.

This function is deprecated. New code should use ParseReference and/or Reference.URL instead.

func MustParseURL

func MustParseURL(url string) *URL

MustParseURL works like ParseURL, but panics in case of errors.

func ParseURL

func ParseURL(urlStr string) (*URL, error)

ParseURL parses the provided charm URL string into its respective structure.

func (*URL) GetBSON

func (u *URL) GetBSON() (interface{}, error)

GetBSON turns u into a bson.Getter so it can be saved directly on a MongoDB database with mgo.

func (*URL) MarshalJSON

func (u *URL) MarshalJSON() ([]byte, error)

func (*URL) Path

func (u *URL) Path() string

func (*URL) Reference

func (u *URL) Reference() *Reference

Reference returns a reference aliased to u. Note that all URLs are valid references.

func (*URL) SetBSON

func (u *URL) SetBSON(raw bson.Raw) error

SetBSON turns u into a bson.Setter so it can be loaded directly from a MongoDB database with mgo.

func (*URL) String

func (u *URL) String() string

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(b []byte) error

func (*URL) WithRevision

func (url *URL) WithRevision(revision int) *URL

WithRevision returns a URL equivalent to url but with Revision set to revision.

type UnitPlacement

type UnitPlacement struct {
	// ContainerType holds the container type of the new
	// new unit, or empty if unspecified.
	ContainerType string

	// Machine holds the numeric machine id, or "new",
	// or empty if the placement specifies a service.
	Machine string

	// Service holds the service name, or empty if
	// the placement specifies a machine.
	Service string

	// Unit holds the unit number of the service, or -1
	// if unspecified.
	Unit int
}

func ParsePlacement

func ParsePlacement(p string) (*UnitPlacement, error)

ParsePlacement parses a unit placement directive, as specified in the To clause of a service entry in the services section of a bundle.

type VerificationError

type VerificationError struct {
	Errors []error
}

VerificationError holds an error generated by BundleData.Verify, holding all the verification errors found when verifying.

func (*VerificationError) Error

func (err *VerificationError) Error() string

Directories

Path Synopsis
hooks provides types and constants that define the hooks known to Juju.
hooks provides types and constants that define the hooks known to Juju.

Jump to

Keyboard shortcuts

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