Documentation
¶
Index ¶
- Constants
- func ValidateConsulConfig(ctx context.Context, tr it.Transport, req *ValidateFileRequest) error
- func ValidateConsulLicense(ctx context.Context, tr it.Transport, req *ValidateFileRequest) error
- func Version(ctx context.Context, tr it.Transport, req *CLIRequest) (semver.Version, error)
- type AgentHostRequest
- type AgentHostRequestOpt
- type AgentHostResponse
- type AgentHostResponseHost
- type CLIRequest
- type CheckStater
- type HealthNodeRequest
- type HealthNodeRequestOpt
- type HealthNodeResponse
- type HealthStatePassingRequest
- type HealthStatePassingRequestOpt
- type HealthStatePassingResponse
- type NodeHealth
- type RaftConfigurationRequest
- type RaftConfigurationRequestOpt
- type RaftConfigurationResponse
- type RaftServer
- type State
- type StateRequest
- type StateRequestOpt
- type ValidateFileRequest
- type ValidateFileRequestOpt
Constants ¶
const NodeHealthStatusHealthy = "passing"
NodeHealthStatusHealthy is the "healthy" status of a node.
Variables ¶
This section is empty.
Functions ¶
func ValidateConsulConfig ¶
ValidateConsulConfig validates the consul config using the consul validate command.
func ValidateConsulLicense ¶
ValidateConsulLicense validates the consul license using file path or env variable.
Types ¶
type AgentHostRequest ¶
AgentHostRequest is a consul /v1/agent/host request.
func NewAgentHostRequest ¶
func NewAgentHostRequest(opts ...AgentHostRequestOpt) *AgentHostRequest
NewAgentHostRequest takes functional options and returns a new request.
func (*AgentHostRequest) String ¶
func (r *AgentHostRequest) String() string
String returns the request as a string.
type AgentHostRequestOpt ¶
type AgentHostRequestOpt func(*AgentHostRequest) *AgentHostRequest
AgentHostRequestOpt is a functional option agent host requests.
func WithAgentHostRequestConsulAddr ¶
func WithAgentHostRequestConsulAddr(addr string) AgentHostRequestOpt
WithAgentHostRequestConsulAddr sets the consul bind address.
func WithAgentHostRequestFlightControlPath ¶
func WithAgentHostRequestFlightControlPath(path string) AgentHostRequestOpt
WithAgentHostRequestFlightControlPath sets the path to flightcontrol.
type AgentHostResponse ¶
type AgentHostResponse struct {
Host *AgentHostResponseHost `json:"Host"`
}
AgentHostRequest is a consul /v1/agent/host response.
func GetAgentHost ¶
func GetAgentHost(ctx context.Context, tr it.Transport, req *AgentHostRequest) ( *AgentHostResponse, error, )
GetAgentHost gets the agent host response.
func (*AgentHostResponse) Hostname ¶
func (r *AgentHostResponse) Hostname() string
Hostname returns the hostname of the host.
type AgentHostResponseHost ¶
AgentHostResponseHost is the Host section of the response.
type CLIRequest ¶
type CLIRequest struct {
BinPath string
}
CLIRequest are common things that we need when making a CLI request.
type CheckStater ¶
CheckStater is a validate function that takes a state and checks that it has expected values.
func CheckStateClusterHasLeader ¶
func CheckStateClusterHasLeader() CheckStater
CheckStateClusterHasLeader checks whether or not the consul cluster has a leader.
func CheckStateClusterHasMinNHealthyNodes ¶
func CheckStateClusterHasMinNHealthyNodes(min uint) CheckStater
CheckStateClusterHasMinNHealthyNodes checks whether or not the cluster has a minimum of N healthy nodes.
func CheckStateClusterHasMinNVoters ¶
func CheckStateClusterHasMinNVoters(min uint) CheckStater
CheckStateClusterHasMinNVoters checks whether or not the cluster has a minimum of N raft voters.
func CheckStateHasSystemdEnabledAndRunningProperties ¶
func CheckStateHasSystemdEnabledAndRunningProperties() CheckStater
CheckStateHasSystemdEnabledAndRunningProperties checks that the consul systemd service has all of the properties and values we expect for a service to be running.
func CheckStateNodeIsHealthy ¶
func CheckStateNodeIsHealthy() CheckStater
CheckStateNodeIsHealthy checks whether or not the consul node is healthy.
type HealthNodeRequest ¶
HealthNodeRequest is a consul /v1/health/node/:node request.
func NewHealthNodeRequest ¶
func NewHealthNodeRequest(opts ...HealthNodeRequestOpt) *HealthNodeRequest
NewHealthNodeRequest takes functional options and returns a new request.
func (*HealthNodeRequest) String ¶
func (r *HealthNodeRequest) String() string
String returns the request as a string.
type HealthNodeRequestOpt ¶
type HealthNodeRequestOpt func(*HealthNodeRequest) *HealthNodeRequest
HealthNodeRequestOpt is a functional option agent host requests.
func WithHealthNodeRequestConsulAddr ¶
func WithHealthNodeRequestConsulAddr(addr string) HealthNodeRequestOpt
WithHealthNodeRequestConsulAddr sets consul bind address.
func WithHealthNodeRequestFlightControlPath ¶
func WithHealthNodeRequestFlightControlPath(path string) HealthNodeRequestOpt
WithHealthNodeRequestFlightControlPath sets the path to flightcontrol.
func WithHealthNodeRequestNodeName ¶
func WithHealthNodeRequestNodeName(name string) HealthNodeRequestOpt
WithHealthNodeRequestNodeName sets the node name we're getting the health for.
type HealthNodeResponse ¶
type HealthNodeResponse struct {
Nodes []*NodeHealth `json:""`
}
HealthNodeResponse is a consul /v1/health/node/:node response.
func GetHealthNode ¶
func GetHealthNode(ctx context.Context, tr it.Transport, req *HealthNodeRequest) ( *HealthNodeResponse, error, )
GetHealthNode gets the agent host response.
func (*HealthNodeResponse) String ¶
func (n *HealthNodeResponse) String() string
String returns the NodeHealthResponse as a string.
type HealthStatePassingRequest ¶
HealthStatePassingRequest is a consul /v1/health/state/passing request.
func NewHealthStatePassingRequest ¶
func NewHealthStatePassingRequest(opts ...HealthStatePassingRequestOpt) *HealthStatePassingRequest
NewHealthStatePassingRequest takes functional options and returns a new request.
func (*HealthStatePassingRequest) String ¶
func (r *HealthStatePassingRequest) String() string
String returns the request as a string.
type HealthStatePassingRequestOpt ¶
type HealthStatePassingRequestOpt func(*HealthStatePassingRequest) *HealthStatePassingRequest
HealthStatePassingRequestOpt is a functional option agent host requests.
func WithHealthStatePassingRequestConsulAddr ¶
func WithHealthStatePassingRequestConsulAddr(addr string) HealthStatePassingRequestOpt
WithHealthStatePassingRequestConsulAddr sets the consul bind address.
func WithHealthStatePassingRequestFlightControlPath ¶
func WithHealthStatePassingRequestFlightControlPath(path string) HealthStatePassingRequestOpt
WithHealthStatePassingRequestFlightControlPath sets the path to flightcontrol.
type HealthStatePassingResponse ¶
type HealthStatePassingResponse struct {
Nodes []*NodeHealth `json:""`
}
HealthStatePassingRequest is a consul /v1/health/state/passing response.
func GetHealthStatePassing ¶
func GetHealthStatePassing(ctx context.Context, tr it.Transport, req *HealthStatePassingRequest) ( *HealthStatePassingResponse, error, )
GetHealthStatePassing gets the agent host response.
func (*HealthStatePassingResponse) String ¶
func (n *HealthStatePassingResponse) String() string
String returns the NodeHealthResponse as a string.
type NodeHealth ¶
type NodeHealth struct { Node string `json:"Node"` Status string `json:"Status"` Output string `json:"Output"` Notes string `json:"Notes"` }
NodeHealth is the Node section of the response.
func (*NodeHealth) String ¶
func (n *NodeHealth) String() string
String returns the NodeHealth as a string.
type RaftConfigurationRequest ¶
RaftConfigurationRequest is a consul /v1/operator/raft/configuration request.
func NewRaftConfigurationRequest ¶
func NewRaftConfigurationRequest(opts ...RaftConfigurationRequestOpt) *RaftConfigurationRequest
NewRaftConfigurationRequest takes functional options and returns a new request.
func (*RaftConfigurationRequest) String ¶
func (r *RaftConfigurationRequest) String() string
String returns the request as a string.
type RaftConfigurationRequestOpt ¶
type RaftConfigurationRequestOpt func(*RaftConfigurationRequest) *RaftConfigurationRequest
RaftConfigurationRequestOpt is a functional option agent host requests.
func WithRaftConfigurationRequestConsulAddr ¶
func WithRaftConfigurationRequestConsulAddr(addr string) RaftConfigurationRequestOpt
WithRaftConfigurationRequestConsulAddr sets the consul bind address.
func WithRaftConfigurationRequestFlightControlPath ¶
func WithRaftConfigurationRequestFlightControlPath(path string) RaftConfigurationRequestOpt
WithRaftConfigurationRequestFlightControlPath sets the path to flightcontrol.
type RaftConfigurationResponse ¶
type RaftConfigurationResponse struct {
Servers []*RaftServer `json:"Servers"`
}
RaftConfigurationResponse is a consul /v1/operator/raft/configuration response.
func GetRaftConfiguration ¶
func GetRaftConfiguration(ctx context.Context, tr it.Transport, req *RaftConfigurationRequest) ( *RaftConfigurationResponse, error, )
GetRaftConfiguration gets the agent host response.
func (*RaftConfigurationResponse) String ¶
func (r *RaftConfigurationResponse) String() string
String returns the raft configuration response as a string.
type RaftServer ¶
type RaftServer struct { ID string `json:"ID"` Node string `json:"Node"` Address string `json:"Address"` Leader bool `json:"Leader"` ProtocolVersion json.Number `json:"ProtocolVersion"` Voter bool `json:"Voter"` }
RaftServer is raft server.
func (*RaftServer) String ¶
func (s *RaftServer) String() string
String returns the RaftServer as a string.
type State ¶
type State struct { *AgentHostResponse // /v1/agent/host *HealthNodeResponse // /v1/health/node/:node *HealthStatePassingResponse // /v1/health/state/passing *RaftConfigurationResponse // /v1/operator/raft/configuration systemd.UnitProperties // systemd unit properties for consul.service }
State represents the state of a node in a consul cluster.
func WaitForState ¶
func WaitForState(ctx context.Context, tr it.Transport, req *StateRequest, checks ...CheckStater) (*State, error)
WaitForState waits until the consul cluster node state satisfies all of the provided checks.
type StateRequest ¶
type StateRequest struct { FlightControlPath string // where enos-flight-control is installed FlightControlUseHomeDir bool // install enos-flight-control into the $HOME directory SystemdUnitName string // what the systemd unit name for the consul service is ConsulAddr string // consul bind address }
StateRequest is a consul status request.
func NewStateRequest ¶
func NewStateRequest(opts ...StateRequestOpt) *StateRequest
NewStateRequest takes functional options and returns a new systemd unit request.
type StateRequestOpt ¶
type StateRequestOpt func(*StateRequest) *StateRequest
StateRequestOpt is a functional option for a config create request.
func WithStateRequestConsulAddr ¶
func WithStateRequestConsulAddr(addr string) StateRequestOpt
WithStateRequestConsulAddr sets the consul bind address.
func WithStateRequestFlightControlPath ¶
func WithStateRequestFlightControlPath(path string) StateRequestOpt
WithStateRequestFlightControlPath sets the enos-flight-control binary path.
func WithStateRequestFlightControlUseHomeDir ¶
func WithStateRequestFlightControlUseHomeDir() StateRequestOpt
WithStateRequestFlightControlUseHomeDir will use the $HOME directory for the enos-flight-control binary path.
func WithStateRequestSystemdUnitName ¶
func WithStateRequestSystemdUnitName(name string) StateRequestOpt
WithStateRequestSystemdUnitName sets the flightcontrol binary path.
type ValidateFileRequest ¶
type ValidateFileRequest struct { *CLIRequest FilePath string Username string }
ValidateFileRequest is a Consul Config Validation request.
func NewValidateFileRequest ¶
func NewValidateFileRequest(opts ...ValidateFileRequestOpt) *ValidateFileRequest
NewValidateFileRequest takes functional options and returns a new config validate request.
type ValidateFileRequestOpt ¶
type ValidateFileRequestOpt func(*ValidateFileRequest) *ValidateFileRequest
ValidateFileRequestOpt is a functional option for a Consul validate command.
func WithValidateConfigBinPath ¶
func WithValidateConfigBinPath(path string) ValidateFileRequestOpt
WithValidateConfigBinPath sets the Consul binary path.
func WithValidateFilePath ¶
func WithValidateFilePath(path string) ValidateFileRequestOpt
WithValidateFilePath sets the Consul config path.
func WithValidateUsername ¶
func WithValidateUsername(name string) ValidateFileRequestOpt
WithValidateUsername sets the username to sudo as for validation.