Documentation ¶
Index ¶
Constants ¶
This section is empty.
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 Connection ¶
type Connection struct { // The User that we should use for the connection. Defaults to root. User string `json:"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"` // The SSH Private Key that we should use for the connection. One of Password or PrivateKey is required. PrivateKey takes the precedence. PrivateKey string `json:"private_key,omitempty"` // The address of the Host to connect to. Defaults to the hostname specified during the registration. Host string `json:"host,omitempty"` // The Port to connect to. Defaults to 22 if set to 0. Port uint64 `json:"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"` }
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 Remove(hostname string) 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, error) GetHost(hostname string) (Host, error) Allocate(message string, filters ...labelsutil.Filter) (string, []labelsutil.Warning, error) Release(hostname string) 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.