Documentation ¶
Index ¶
- Variables
- func IsValidName(name string) bool
- func IsValidSeries(series string) bool
- func IsValidUser(user string) bool
- func Latest(repo Repository, curl *URL) (int, error)
- func Quote(unsafe string) string
- type ActionSpec
- type Actions
- type Bundle
- type Charm
- type CharmRevision
- type CharmStore
- func (s *CharmStore) BranchLocation(curl *URL) string
- func (s *CharmStore) CharmURL(location string) (*URL, error)
- func (s *CharmStore) Event(curl *URL, digest string) (*EventResponse, error)
- func (s *CharmStore) Get(curl *URL) (Charm, error)
- func (s *CharmStore) Info(curls ...Location) ([]*InfoResponse, error)
- func (s *CharmStore) Latest(curls ...*URL) ([]CharmRevision, error)
- func (s *CharmStore) Resolve(ref Reference) (*URL, error)
- func (s *CharmStore) WithAuthAttrs(authAttrs string) Repository
- func (s *CharmStore) WithJujuAttrs(jujuAttrs string) Repository
- func (s *CharmStore) WithTestMode(testMode bool) Repository
- type Config
- func (c *Config) DefaultSettings() Settings
- func (c *Config) FilterSettings(settings Settings) Settings
- func (c *Config) ParseSettingsStrings(values map[string]string) (Settings, error)
- func (c *Config) ParseSettingsYAML(yamlData []byte, key string) (Settings, error)
- func (c *Config) ValidateSettings(settings Settings) (Settings, error)
- type Dir
- type EventResponse
- type InfoResponse
- type LocalRepository
- type Location
- type Meta
- type NotFoundError
- type Option
- type Reference
- type Relation
- type RelationRole
- type RelationScope
- type Repository
- type Settings
- type URL
Constants ¶
This section is empty.
Variables ¶
var CacheDir string
CacheDir stores the charm cache directory path.
var ErrUnresolvedUrl error = fmt.Errorf("charm url series is not resolved")
var Store = &CharmStore{BaseURL: "https://store.juju.ubuntu.com"}
Functions ¶
func IsValidName ¶
IsValidName returns whether name is a valid charm name.
func IsValidSeries ¶
IsValidSeries returns whether series is a valid series in charm URLs.
func IsValidUser ¶
IsValidUser returns whether user is a valid username in charm URLs.
Types ¶
type ActionSpec ¶
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)
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
type Bundle ¶
type Bundle struct { Path string // May be empty if Bundle wasn't read from a file // contains filtered or unexported fields }
The Bundle type encapsulates access to data and operations on a charm bundle.
func ReadBundle ¶
ReadBundle returns a Bundle for the charm in path.
func ReadBundleBytes ¶
ReadBundleBytes returns a Bundle read from the given data. Make sure the bundle fits in memory before using this.
func (*Bundle) Actions ¶
Actions returns the Actions map for the actions.yaml file for the charm bundle.
func (*Bundle) Config ¶
Config returns the Config representing the config.yaml file for the charm bundle.
func (*Bundle) ExpandTo ¶
ExpandTo expands the charm bundle into dir, creating it if necessary. If any errors occur during the expansion procedure, the process will abort.
func (*Bundle) SetRevision ¶
SetRevision changes the charm revision number. This affects the revision reported by Revision and the revision of the charm directory created by ExpandTo.
type CharmRevision ¶
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, resolving references and implied series.
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 ¶
Config represents the supported configuration options for a charm, as declared in its config.yaml file.
func ReadConfig ¶
ReadConfig reads a Config in YAML format.
func (*Config) DefaultSettings ¶
DefaultSettings returns settings containing the default value of every option in the config. Default values may be nil.
func (*Config) FilterSettings ¶
FilterSettings returns the subset of the supplied settings that are valid.
func (*Config) ParseSettingsStrings ¶
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 ¶
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.
type Dir ¶
type Dir struct { Path string // contains filtered or unexported fields }
The Dir type encapsulates access to data and operations on a charm directory.
func (*Dir) Actions ¶
Actions returns the Actions representing the actions.yaml file for the charm expanded in dir.
func (*Dir) BundleTo ¶
BundleTo creates a charm file from the charm expanded in dir. By convention a charm bundle should have a ".charm" suffix.
func (*Dir) Config ¶
Config returns the Config representing the config.yaml file for the charm expanded in dir.
func (*Dir) Meta ¶
Meta returns the Meta representing the metadata.yaml file for the charm expanded in dir.
func (*Dir) SetDiskRevision ¶
SetDiskRevision does the same as SetRevision but also changes the revision file in the charm directory.
func (*Dir) SetRevision ¶
SetRevision changes the charm revision number. This affects the revision reported by Revision and the revision of the charm bundled by BundleTo. The revision file in the charm directory is not modified.
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 ¶
Location represents a charm location, which must declare a path component and a string representaion.
type Meta ¶
type Meta struct { Name string Summary string Description string Subordinate bool Provides map[string]Relation `bson:",omitempty"` Requires map[string]Relation `bson:",omitempty"` Peers map[string]Relation `bson:",omitempty"` Format int `bson:",omitempty"` OldRevision int `bson:",omitempty"` // Obsolete Categories []string `bson:",omitempty"` Series string `bson:",omitempty"` }
Meta represents all the known content that may be defined within a charm's metadata.yaml file.
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 Reference ¶
type Reference struct { Schema string // "cs" or "local" User string // "joe" Name string // "wordpress" Revision int // -1 if unset, N otherwise }
Reference represents a charm location with an unresolved, untargeted series, such as:
cs:~joe/wordpress cs:wordpress-42
func ParseReference ¶
ParseReference parses the provided charm Reference string into its respective structure and the targeted series, if present.
func (*Reference) MarshalJSON ¶
func (*Reference) UnmarshalJSON ¶
type Relation ¶
type Relation struct { Name string Role RelationRole Interface string Optional bool Limit int Scope RelationScope }
Relation represents a single relation defined in the charm metadata.yaml file.
func (Relation) ImplementedBy ¶
ImplementedBy returns whether the relation is implemented by the supplied charm.
func (Relation) IsImplicit ¶
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 reference. Local references will use the provided path.
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 URL ¶
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 ¶
InferURL returns a charm URL inferred from src. The provided src may be a valid URL, in which case it is returned as-is, 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 cs:~user/name cs:~user/name-revision
The defaultSeries paramater is used to define the resulting URL when src does not include that information; similarly, a missing schema is assumed to be 'cs'.
func MustParseURL ¶
MustParseURL works like ParseURL, but panics in case of errors.
func (*URL) GetBSON ¶
GetBSON turns u into a bson.Getter so it can be saved directly on a MongoDB database with mgo.
func (*URL) MarshalJSON ¶
func (*URL) SetBSON ¶
SetBSON turns u into a bson.Setter so it can be loaded directly from a MongoDB database with mgo.
func (*URL) UnmarshalJSON ¶
func (*URL) WithRevision ¶
WithRevision returns a URL equivalent to url but with Revision set to revision.