Documentation ¶
Index ¶
- Constants
- type Client
- type ConsulAgentConfig
- type ConsulClient
- func (c *ConsulClient) DeregisterService(ctx context.Context, serviceID string, q *consulapi.QueryOptions) error
- func (c *ConsulClient) GetHealthChecks(ctx context.Context, serviceName string, opts *consulapi.QueryOptions) (consulapi.HealthChecks, error)
- func (c *ConsulClient) GetLicense(ctx context.Context, q *consulapi.QueryOptions) (string, error)
- func (c *ConsulClient) KVGet(ctx context.Context, key string, q *consulapi.QueryOptions) (*consulapi.KVPair, *consulapi.QueryMeta, error)
- func (c *ConsulClient) Lock(l *consulapi.Lock, stopCh <-chan struct{}) (<-chan struct{}, error)
- func (c *ConsulClient) QueryServices(ctx context.Context, filter string, opts *consulapi.QueryOptions) ([]*consulapi.AgentService, error)
- func (c *ConsulClient) RegisterService(ctx context.Context, r *consulapi.AgentServiceRegistration) error
- func (c *ConsulClient) SessionCreate(ctx context.Context, se *consulapi.SessionEntry, q *consulapi.WriteOptions) (string, *consulapi.WriteMeta, error)
- func (c *ConsulClient) SessionRenewPeriodic(initialTTL string, id string, q *consulapi.WriteOptions, ...) error
- func (c *ConsulClient) Unlock(l *consulapi.Lock) error
- type ConsulClientInterface
- type MissingConsulACLError
- type NonEnterpriseConsulError
- type Printer
- func (p *Printer) Apply(context.Context) error
- func (p *Printer) GoString() string
- func (p *Printer) Init(context.Context) error
- func (p *Printer) Plan(context.Context) (bool, error)
- func (p *Printer) SetEnv(map[string]string) error
- func (p *Printer) SetStdout(io.Writer)
- func (p *Printer) Validate(context.Context) error
- type PrinterConfig
- type TerraformCLI
- func (t *TerraformCLI) Apply(ctx context.Context) error
- func (t *TerraformCLI) GoString() string
- func (t *TerraformCLI) Init(ctx context.Context) error
- func (t *TerraformCLI) Plan(ctx context.Context) (bool, error)
- func (t *TerraformCLI) SetEnv(env map[string]string) error
- func (t *TerraformCLI) SetStdout(w io.Writer)
- func (t *TerraformCLI) Validate(ctx context.Context) error
- type TerraformCLIConfig
Constants ¶
const (
ConsulDefaultMaxRetry = 8 // to be consistent with hcat retries
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // SetEnv Set the environment for the client SetEnv(map[string]string) error // SetStdout Set the standard out for the client SetStdout(w io.Writer) // Init initializes the client and environment Init(ctx context.Context) error // Apply makes a request to apply changes Apply(ctx context.Context) error // Plan makes a request to generate a plan of proposed changes Plan(ctx context.Context) (bool, error) // Validate verifies that the generated configurations are valid Validate(ctx context.Context) error // GoString defines the printable version of the client GoString() string }
Client describes the interface for a driver's client that interacts with network infrastructure.
type ConsulAgentConfig ¶ added in v0.6.0
ConsulAgentConfig represents the responseCode body from Consul /v1/agent/self API endpoint. The response contains configuration and member information of the requested agent. Care must always be taken to do type checks when casting, as structure could potentially change over time.
type ConsulClient ¶ added in v0.6.0
ConsulClient is a client to the Consul API
func NewConsulClient ¶ added in v0.6.0
func NewConsulClient(conf *config.ConsulConfig, maxRetry int) (*ConsulClient, error)
NewConsulClient constructs a consul api client
func (*ConsulClient) DeregisterService ¶ added in v0.6.0
func (c *ConsulClient) DeregisterService(ctx context.Context, serviceID string, q *consulapi.QueryOptions) error
DeregisterService removes a service through the Consul agent.
func (*ConsulClient) GetHealthChecks ¶ added in v0.7.0
func (c *ConsulClient) GetHealthChecks(ctx context.Context, serviceName string, opts *consulapi.QueryOptions) (consulapi.HealthChecks, error)
GetHealthChecks is used to return the health checks associated with a service
func (*ConsulClient) GetLicense ¶ added in v0.6.0
func (c *ConsulClient) GetLicense(ctx context.Context, q *consulapi.QueryOptions) (string, error)
GetLicense queries Consul for a signed license, and returns it if available GetLicense is a Consul Enterprise only endpoint, a 404 returned assumes we are connected to OSS Consul GetLicense does not require any ACLs
func (*ConsulClient) KVGet ¶ added in v0.7.0
func (c *ConsulClient) KVGet(ctx context.Context, key string, q *consulapi.QueryOptions) (*consulapi.KVPair, *consulapi.QueryMeta, error)
KVGet fetches a Consul KV pair, retrying the request on server errors and rate limit errors.
func (*ConsulClient) Lock ¶ added in v0.7.0
func (c *ConsulClient) Lock(l *consulapi.Lock, stopCh <-chan struct{}) (<-chan struct{}, error)
Lock attempts to acquire the given lock.
func (*ConsulClient) QueryServices ¶ added in v0.7.0
func (c *ConsulClient) QueryServices(ctx context.Context, filter string, opts *consulapi.QueryOptions) ([]*consulapi.AgentService, error)
QueryServices returns a subset of the locally registered services that match the given filter expression and QueryOptions.
func (*ConsulClient) RegisterService ¶ added in v0.6.0
func (c *ConsulClient) RegisterService(ctx context.Context, r *consulapi.AgentServiceRegistration) error
RegisterService registers a service through the Consul agent.
func (*ConsulClient) SessionCreate ¶ added in v0.7.0
func (c *ConsulClient) SessionCreate(ctx context.Context, se *consulapi.SessionEntry, q *consulapi.WriteOptions) (string, *consulapi.WriteMeta, error)
SessionCreate initializes a new session, retrying creation requests on server errors and rate limit errors.
func (*ConsulClient) SessionRenewPeriodic ¶ added in v0.7.0
func (c *ConsulClient) SessionRenewPeriodic(initialTTL string, id string, q *consulapi.WriteOptions, doneCh <-chan struct{}) error
SessionRenewPeriodic renews a session on a given cadence.
type ConsulClientInterface ¶ added in v0.6.0
type ConsulClientInterface interface { GetLicense(ctx context.Context, q *consulapi.QueryOptions) (string, error) RegisterService(ctx context.Context, s *consulapi.AgentServiceRegistration) error DeregisterService(ctx context.Context, serviceID string, q *consulapi.QueryOptions) error SessionCreate(ctx context.Context, se *consulapi.SessionEntry, q *consulapi.WriteOptions) (string, *consulapi.WriteMeta, error) SessionRenewPeriodic(initialTTL string, id string, q *consulapi.WriteOptions, doneCh <-chan struct{}) error LockOpts(opts *consulapi.LockOptions) (*consulapi.Lock, error) Lock(l *consulapi.Lock, stopCh <-chan struct{}) (<-chan struct{}, error) Unlock(l *consulapi.Lock) error KVGet(ctx context.Context, key string, q *consulapi.QueryOptions) (*consulapi.KVPair, *consulapi.QueryMeta, error) QueryServices(ctx context.Context, filter string, q *consulapi.QueryOptions) ([]*consulapi.AgentService, error) GetHealthChecks(ctx context.Context, serviceName string, q *consulapi.QueryOptions) (consulapi.HealthChecks, error) }
ConsulClientInterface is an interface for a Consul Client If more consul client functionality is required, this interface should be extended with the following considerations: Each request to Consul is: - Retried - Logged at DEBUG-level - Easily mocked
type MissingConsulACLError ¶ added in v0.6.0
type MissingConsulACLError struct {
Err error
}
MissingConsulACLError represents an error returned if the error was due to not having the correct ACL for accessing a Consul resource
func (*MissingConsulACLError) Error ¶ added in v0.6.0
func (e *MissingConsulACLError) Error() string
Error returns an error string
func (*MissingConsulACLError) Unwrap ¶ added in v0.6.0
func (e *MissingConsulACLError) Unwrap() error
Unwrap returns the underlying error
type NonEnterpriseConsulError ¶ added in v0.6.0
type NonEnterpriseConsulError struct {
Err error
}
NonEnterpriseConsulError represents an error returned if expected enterprise Consul, but enterprise Consul was not found
func (*NonEnterpriseConsulError) Error ¶ added in v0.6.0
func (e *NonEnterpriseConsulError) Error() string
Error returns an error string
func (*NonEnterpriseConsulError) Unwrap ¶ added in v0.6.0
func (e *NonEnterpriseConsulError) Unwrap() error
Unwrap returns the underlying error
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer is a fake client that only logs out actions. Intended to mirror TerraformCLI client and to be used for development only
func NewPrinter ¶
func NewPrinter(config *PrinterConfig) (*Printer, error)
NewPrinter creates a new client
type PrinterConfig ¶
PrinterConfig configures the log client
type TerraformCLI ¶
type TerraformCLI struct {
// contains filtered or unexported fields
}
TerraformCLI is the client that wraps around terraform-exec to execute Terraform cli commands
func NewTerraformCLI ¶
func NewTerraformCLI(config *TerraformCLIConfig) (*TerraformCLI, error)
NewTerraformCLI creates a terraform-exec client and configures and initializes a new Terraform client
func (*TerraformCLI) Apply ¶
func (t *TerraformCLI) Apply(ctx context.Context) error
Apply executes the cli command `terraform apply` for a given workspace
func (*TerraformCLI) GoString ¶
func (t *TerraformCLI) GoString() string
GoString defines the printable version of this struct.
func (*TerraformCLI) Init ¶
func (t *TerraformCLI) Init(ctx context.Context) error
Init initializes by executing the cli command `terraform init` and `terraform workspace new <name>`
func (*TerraformCLI) Plan ¶
func (t *TerraformCLI) Plan(ctx context.Context) (bool, error)
Plan executes the cli command `terraform plan` for a given workspace
func (*TerraformCLI) SetEnv ¶
func (t *TerraformCLI) SetEnv(env map[string]string) error
SetEnv sets the environment for the Terraform workspace
func (*TerraformCLI) SetStdout ¶
func (t *TerraformCLI) SetStdout(w io.Writer)
SetStdout sets the standard out for Terraform