Documentation ¶
Overview ¶
The description package defines the structure and representation and serialisation of models to facilitate the import and export of models from different controllers.
Index ¶
- func Serialize(model Model) ([]byte, error)
- type Address
- type AddressArgs
- type AgentTools
- type AgentToolsArgs
- type Annotations_
- type ByName
- type CloudInstance
- type CloudInstanceArgs
- type Constraints
- type ConstraintsArgs
- type Endpoint
- type EndpointArgs
- type HasAnnotations
- type HasConstraints
- type HasStatusHistory
- type Machine
- type MachineArgs
- type Model
- type ModelArgs
- type OpenedPorts
- type OpenedPortsArgs
- type PortRange
- type PortRangeArgs
- type Relation
- type RelationArgs
- type Service
- type ServiceArgs
- type Status
- type StatusArgs
- type StatusHistory_
- type StatusPoint_
- type Unit
- type UnitArgs
- type User
- type UserArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddressArgs ¶
AddressArgs is an argument struct used to create a new internal address type that supports the Address interface.
type AgentTools ¶
AgentTools represent the version and related binary file that the machine and unit agents are using.
type AgentToolsArgs ¶
AgentToolsArgs is an argument struct used to add information about the tools the agent is using to a Machine.
type Annotations_ ¶
Instead of copy / pasting the Annotations, SetAnnotations, and the import three lines into every entity that has annotations, the Annotations_ helper type is provided for use in composition. This type is composed without a name so the methods get promoted so they satisfy the HasAnnotations interface.
NOTE(mjs) - The type is exported due to a limitation with go-yaml under 1.6. Once that's fixed it should be possible to make it private again.
NOTE(mjs) - The trailing underscore on the type name is to avoid collisions between the type name and the Annotations method. The underscore can go once the type becomes private again (revert to "annotations").
func (*Annotations_) Annotations ¶
func (a *Annotations_) Annotations() map[string]string
Annotations implements HasAnnotations.
func (*Annotations_) SetAnnotations ¶
func (a *Annotations_) SetAnnotations(annotations map[string]string)
SetAnnotations implements HasAnnotations.
type CloudInstance ¶
type CloudInstance interface { InstanceId() string Status() string Architecture() string Memory() uint64 RootDisk() uint64 CpuCores() uint64 CpuPower() uint64 Tags() []string AvailabilityZone() string }
CloudInstance holds information particular to a machine instance in a cloud.
type CloudInstanceArgs ¶
type CloudInstanceArgs struct { InstanceId string Status string Architecture string Memory uint64 RootDisk uint64 CpuCores uint64 CpuPower uint64 Tags []string AvailabilityZone string }
CloudInstanceArgs is an argument struct used to add information about the cloud instance to a Machine.
type Constraints ¶
type Constraints interface { Architecture() string Container() string CpuCores() uint64 CpuPower() uint64 InstanceType() string Memory() uint64 RootDisk() uint64 Spaces() []string Tags() []string }
Constraints holds information about particular deployment constraints for entities.
type ConstraintsArgs ¶
type ConstraintsArgs struct { Architecture string Container string CpuCores uint64 CpuPower uint64 InstanceType string Memory uint64 RootDisk uint64 Spaces []string Tags []string }
ConstraintsArgs is an argument struct to construct Constraints.
type Endpoint ¶
type Endpoint interface { ServiceName() string Name() string // Role, Interface, Optional, Limit, and Scope should all be available // through the Charm associated with the Service. There is no real need // for this information to be denormalised like this. However, for now, // since the import may well take place before the charms have been loaded // into the model, we'll send this information over. Role() string Interface() string Optional() bool Limit() int Scope() string // UnitCount returns the number of units the endpoint has settings for. UnitCount() int Settings(unitName string) map[string]interface{} SetUnitSettings(unitName string, settings map[string]interface{}) }
Endpoint represents one end of a relation. A named endpoint provided by the charm that is deployed for the service.
type EndpointArgs ¶
type EndpointArgs struct { ServiceName string Name string Role string Interface string Optional bool Limit int Scope string }
EndpointArgs is an argument struct used to specify a relation.
type HasAnnotations ¶
HasAnnotations defines the common methods for setting and getting annotations for the various entities.
type HasConstraints ¶
type HasConstraints interface { Constraints() Constraints SetConstraints(ConstraintsArgs) }
HasConstraints defines the common methods for setting and getting constraints for the various entities.
type HasStatusHistory ¶
type HasStatusHistory interface { StatusHistory() []Status SetStatusHistory([]StatusArgs) }
HasStatusHistory defines the common methods for setting and getting historical status entries for the various entities.
type Machine ¶
type Machine interface { HasAnnotations HasConstraints HasStatusHistory Id() string Tag() names.MachineTag Nonce() string PasswordHash() string Placement() string Series() string ContainerType() string Jobs() []string SupportedContainers() ([]string, bool) Instance() CloudInstance SetInstance(CloudInstanceArgs) // Life() string -- only transmit alive things? ProviderAddresses() []Address MachineAddresses() []Address SetAddresses(machine []AddressArgs, provider []AddressArgs) PreferredPublicAddress() Address PreferredPrivateAddress() Address SetPreferredAddresses(public AddressArgs, private AddressArgs) Tools() AgentTools SetTools(AgentToolsArgs) Containers() []Machine AddContainer(MachineArgs) Machine Status() Status SetStatus(StatusArgs) OpenedPorts() []OpenedPorts AddOpenedPorts(OpenedPortsArgs) OpenedPorts // THINKING: Validate() error to make sure the machine has // enough stuff set, like tools, and addresses etc. Validate() error }
Machine represents an existing live machine or container running in the model.
type MachineArgs ¶
type MachineArgs struct { Id names.MachineTag Nonce string PasswordHash string Placement string Series string ContainerType string Jobs []string // A null value means that we don't yet know which containers // are supported. An empty slice means 'no containers are supported'. SupportedContainers *[]string }
MachineArgs is an argument struct used to add a machine to the Model.
type Model ¶
type Model interface { HasAnnotations HasConstraints Tag() names.ModelTag Owner() names.UserTag Config() map[string]interface{} LatestToolsVersion() version.Number // UpdateConfig overwrites existing config values with those specified. UpdateConfig(map[string]interface{}) // Blocks returns a map of block type to the message associated with that // block. Blocks() map[string]string Users() []User AddUser(UserArgs) Machines() []Machine AddMachine(MachineArgs) Machine Services() []Service AddService(ServiceArgs) Service Relations() []Relation AddRelation(RelationArgs) Relation Sequences() map[string]int SetSequence(name string, value int) Validate() error }
Model is a database agnostic representation of an existing model.
func Deserialize ¶
Deserialize constructs a Model from a serialized YAML byte stream. The normal use for this is to construct the Model representation after getting the byte stream from an API connection or read from a file.
type ModelArgs ¶
type ModelArgs struct { Owner names.UserTag Config map[string]interface{} LatestToolsVersion version.Number Blocks map[string]string }
ModelArgs represent the bare minimum information that is needed to represent a model.
type OpenedPorts ¶
OpenedPorts represents a collection of port ranges that are open on a particular subnet. OpenedPorts are always associated with a Machine.
type OpenedPortsArgs ¶
type OpenedPortsArgs struct { SubnetID string OpenedPorts []PortRangeArgs }
OpenedPortsArgs is an argument struct used to add a set of opened port ranges to a machine.
type PortRangeArgs ¶
PortRangeArgs is an argument struct used to create a PortRange. This is only done as part of creating OpenedPorts for a Machine.
type Relation ¶
type Relation interface { Id() int Key() string Endpoints() []Endpoint AddEndpoint(EndpointArgs) Endpoint }
Relation represents a relationship between two services, or a peer relation between different instances of a service.
type RelationArgs ¶
RelationArgs is an argument struct used to specify a relation.
type Service ¶
type Service interface { HasAnnotations HasConstraints HasStatusHistory Tag() names.ServiceTag Name() string Series() string Subordinate() bool CharmURL() string Channel() string CharmModifiedVersion() int ForceCharm() bool Exposed() bool MinUnits() int Settings() map[string]interface{} SettingsRefCount() int Leader() string LeadershipSettings() map[string]interface{} MetricsCredentials() []byte Status() Status SetStatus(StatusArgs) Units() []Unit AddUnit(UnitArgs) Unit Validate() error }
Service represents a deployed charm in a model.
type ServiceArgs ¶
type ServiceArgs struct { Tag names.ServiceTag Series string Subordinate bool CharmURL string Channel string CharmModifiedVersion int ForceCharm bool Exposed bool MinUnits int Settings map[string]interface{} SettingsRefCount int Leader string LeadershipSettings map[string]interface{} MetricsCredentials []byte }
ServiceArgs is an argument struct used to add a service to the Model.
type Status ¶
type Status interface { Value() string Message() string Data() map[string]interface{} Updated() time.Time }
Status represents an agent, service, or workload status.
type StatusArgs ¶
type StatusArgs struct { Value string Message string Data map[string]interface{} Updated time.Time }
StatusArgs is an argument struct used to set the agent, service, or workload status.
type StatusHistory_ ¶
type StatusHistory_ struct { Version int `yaml:"version"` History []*StatusPoint_ `yaml:"history"` }
func (*StatusHistory_) SetStatusHistory ¶
func (s *StatusHistory_) SetStatusHistory(args []StatusArgs)
SetStatusHistory implements HasStatusHistory.
func (*StatusHistory_) StatusHistory ¶
func (s *StatusHistory_) StatusHistory() []Status
StatusHistory implements HasStatusHistory.
type StatusPoint_ ¶
type StatusPoint_ struct { Value_ string `yaml:"value"` Message_ string `yaml:"message,omitempty"` Data_ map[string]interface{} `yaml:"data,omitempty"` Updated_ time.Time `yaml:"updated"` }
StatusPoint_ implements Status, and represents the status of an entity at a point in time. Used in the serialization of both status and StatusHistory_.
func (*StatusPoint_) Data ¶
func (a *StatusPoint_) Data() map[string]interface{}
Data implements Status.
func (*StatusPoint_) Updated ¶
func (a *StatusPoint_) Updated() time.Time
Updated implements Status.
type Unit ¶
type Unit interface { HasAnnotations HasConstraints Tag() names.UnitTag Name() string Machine() names.MachineTag PasswordHash() string Principal() names.UnitTag Subordinates() []names.UnitTag MeterStatusCode() string MeterStatusInfo() string Tools() AgentTools SetTools(AgentToolsArgs) WorkloadStatus() Status SetWorkloadStatus(StatusArgs) WorkloadStatusHistory() []Status SetWorkloadStatusHistory([]StatusArgs) AgentStatus() Status SetAgentStatus(StatusArgs) AgentStatusHistory() []Status SetAgentStatusHistory([]StatusArgs) Validate() error }
Unit represents an instance of a service in a model.
type UnitArgs ¶
type UnitArgs struct { Tag names.UnitTag Machine names.MachineTag PasswordHash string Principal names.UnitTag Subordinates []names.UnitTag MeterStatusCode string MeterStatusInfo string }
UnitArgs is an argument struct used to add a Unit to a Service in the Model.