Documentation
¶
Index ¶
Constants ¶
const ( // CheckpointError is an error of checkpoint between the current Hosts Pool // and an apply change request CheckpointError = "Checkpoint for Hosts Pool error" )
Variables ¶
This section is empty.
Functions ¶
func IsBadRequestError ¶
IsBadRequestError checks if an error is an error due to a bad input
func IsHostAlreadyExistError ¶
IsHostAlreadyExistError checks if an error is an "host already exists" error
func IsHostNotFoundError ¶
IsHostNotFoundError checks if an error is an "host not found" error
func IsNoMatchingHostFoundError ¶
IsNoMatchingHostFoundError checks if an error is an error due to no hosts match the given filters if any
Types ¶
type Allocation ¶
type Allocation struct {
ID string `json:"id"`
NodeName string `json:"node_name"`
Instance string `json:"instance"`
DeploymentID string `json:"deployment_id"`
Resources map[string]string `json:"resource_labels,omitempty"`
}
An Allocation describes the related allocation associated to a host pool
func (*Allocation) String ¶
func (alloc *Allocation) String() string
type Connection ¶
type Connection struct {
// The User that we should use for the connection. Defaults to root.
User string `json:"user,omitempty" yaml:"user,omitempty"`
// The Password that we should use for the connection. One of Password or PrivateKey is required. PrivateKey takes the precedence.
Password string `json:"password,omitempty" yaml:"password,omitempty"`
// The SSH Private Key that we should use for the connection. One of Password or PrivateKey is required. PrivateKey takes the precedence.
// The mapstructure tag is needed for viper unmarshalling
PrivateKey string `json:"private_key,omitempty" yaml:"private_key,omitempty" mapstructure:"private_key"`
// The address of the Host to connect to. Defaults to the hostname specified during the registration.
Host string `json:"host,omitempty" yaml:"host,omitempty"`
// The Port to connect to. Defaults to 22 if set to 0.
Port uint64 `json:"port,omitempty" yaml:"port,omitempty"`
}
A Connection holds info used to connect to a host using SSH
func (Connection) String ¶
func (conn Connection) String() string
String allows to stringify a connection
type Host ¶
type Host struct {
Name string `json:"name,omitempty"`
Connection Connection `json:"connection"`
Status HostStatus `json:"status"`
Message string `json:"reason,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Allocations []Allocation `json:"allocations,omitempty"`
}
An Host holds information on an Host as it is known by the hostspool
type HostStatus ¶
type HostStatus int
HostStatus x ENUM( free, allocated, error )
const ( // HostStatusFree is a HostStatus of type Free HostStatusFree HostStatus = iota // HostStatusAllocated is a HostStatus of type Allocated HostStatusAllocated // HostStatusError is a HostStatus of type Error HostStatusError )
func ParseHostStatus ¶
func ParseHostStatus(name string) (HostStatus, error)
ParseHostStatus attempts to convert a string to a HostStatus
func (HostStatus) MarshalJSON ¶
func (hs HostStatus) MarshalJSON() ([]byte, error)
MarshalJSON is used to represent this enumeration as a string instead of an int
func (HostStatus) String ¶
func (i HostStatus) String() string
func (*HostStatus) UnmarshalJSON ¶
func (hs *HostStatus) UnmarshalJSON(b []byte) error
UnmarshalJSON is used to read this enumeration from a string
type Manager ¶
type Manager interface {
Add(hostname string, connection Connection, labels map[string]string) error
Apply(pool []Host, checkpoint *uint64) error
Remove(hostname string) error
UpdateResourcesLabels(hostname string, diff map[string]string, operation func(a int64, b int64) int64, update func(orig map[string]string, diff map[string]string, operation func(a int64, b int64) int64) (map[string]string, error)) error
AddLabels(hostname string, labels map[string]string) error
RemoveLabels(hostname string, labels []string) error
UpdateConnection(hostname string, connection Connection) error
List(filters ...labelsutil.Filter) ([]string, []labelsutil.Warning, uint64, error)
GetHost(hostname string) (Host, error)
Allocate(allocation *Allocation, filters ...labelsutil.Filter) (string, []labelsutil.Warning, error)
Release(hostname string, allocation *Allocation) error
}
A Manager is in charge of creating/updating/deleting hosts from the pool
func NewManager ¶
NewManager creates a Manager backed to Consul
func NewManagerWithSSHFactory ¶
func NewManagerWithSSHFactory(cc *api.Client, sshClientFactory SSHClientFactory) Manager
NewManagerWithSSHFactory creates a Manager with a given ssh factory
Currently this is used for testing purpose to mock the ssh connection.
type SSHClientFactory ¶
type SSHClientFactory func(config *ssh.ClientConfig, conn Connection) sshutil.Client
SSHClientFactory is a that could be called to customize the client used to check the connection.
Currently this is used for testing purpose to mock the ssh connection.