Documentation ¶
Index ¶
- Constants
- Variables
- func InstallTerraform(ctx context.Context, conf *config.TerraformConfig) error
- type BufferPeriod
- type Driver
- type Drivers
- func (d *Drivers) Add(taskName string, driver Driver) error
- func (d *Drivers) Delete(taskName string) error
- func (d *Drivers) Get(taskName string) (Driver, bool)
- func (d *Drivers) GetTaskByTemplate(tmplID string) (Driver, bool)
- func (d *Drivers) IsActive(name string) bool
- func (d *Drivers) IsMarkedForDeletion(name string) bool
- func (d *Drivers) Len() int
- func (d *Drivers) Map() map[string]Driver
- func (d *Drivers) MarkForDeletion(name string)
- func (d *Drivers) Reset(ctx context.Context)
- func (d *Drivers) SetActive(name string) bool
- func (d *Drivers) SetBufferPeriod()
- func (d *Drivers) SetInactive(name string) bool
- type InspectPlan
- type PatchTask
- type Service
- type Task
- func (t *Task) BufferPeriod() (BufferPeriod, bool)
- func (t *Task) Condition() config.ConditionConfig
- func (t *Task) DeprecatedTFVersion() string
- func (t *Task) Description() string
- func (t *Task) Disable()
- func (t *Task) Enable()
- func (t *Task) Env() map[string]string
- func (t *Task) IsEnabled() bool
- func (t *Task) IsScheduled() bool
- func (t *Task) Module() string
- func (t *Task) ModuleInputs() config.ModuleInputConfigs
- func (t *Task) Name() string
- func (t *Task) ProviderIDs() []string
- func (t *Task) Providers() TerraformProviderBlocks
- func (t *Task) ServiceNames() []string
- func (t *Task) Services() []Service
- func (t *Task) TFCWorkspace() config.TerraformCloudWorkspaceConfig
- func (t *Task) Variables() hcltmpl.Variables
- func (t *Task) Version() string
- func (t *Task) WorkingDir() string
- type TaskConfig
- type Terraform
- func (tf *Terraform) ApplyTask(ctx context.Context) error
- func (tf *Terraform) DestroyTask(_ context.Context)
- func (tf *Terraform) InitTask(ctx context.Context) error
- func (tf *Terraform) InspectTask(ctx context.Context) (InspectPlan, error)
- func (tf *Terraform) OnceDone() bool
- func (tf *Terraform) RenderTemplate(_ context.Context) (bool, error)
- func (tf *Terraform) SetBufferPeriod()
- func (tf *Terraform) Task() *Task
- func (tf *Terraform) TemplateIDs() []string
- func (tf *Terraform) UpdateTask(ctx context.Context, patch PatchTask) (InspectPlan, error)
- func (tf *Terraform) Version() string
- type TerraformConfig
- type TerraformProviderBlock
- type TerraformProviderBlocks
Constants ¶
const ( // RunOptionNow runs the task immediate (now) once the task has been updated RunOptionNow = "now" // RunOptionInspect does a dry-run task update and returns dry-run info RunOptionInspect = "inspect" )
Variables ¶
var TerraformVersion *goVersion.Version
TerraformVersion is the version of Terraform CLI for the Terraform driver.
Functions ¶
func InstallTerraform ¶
func InstallTerraform(ctx context.Context, conf *config.TerraformConfig) error
InstallTerraform installs the Terraform binary to the configured path. If an existing Terraform exists in the path, it is checked for compatibility.
Types ¶
type BufferPeriod ¶
BufferPeriod contains the task's buffer period configuration information if enabled
type Driver ¶
type Driver interface { // InitTask initializes the task that the driver executes InitTask(ctx context.Context) error // SetBufferPeriod sets the task's buffer period on the watcher SetBufferPeriod() // TemplateIDs returns the list of template IDs for the driver TemplateIDs() []string // RenderTemplate renders a template. Returns if template rendering // completed or not RenderTemplate(ctx context.Context) (bool, error) // InspectTask inspects for any differences pertaining to the task between // the state of Consul and network infrastructure InspectTask(ctx context.Context) (InspectPlan, error) // ApplyTask applies change for the task managed by the driver ApplyTask(ctx context.Context) error // UpdateTask supports updating certain fields of a task UpdateTask(ctx context.Context, task PatchTask) (InspectPlan, error) // DestroyTask destroys task dependencies so that it can be safely deleted DestroyTask(ctx context.Context) // Task returns the task information of the driver Task() *Task // Version returns the version of the driver. Version() string }
Driver describes the interface for using an CTS driver to carry out changes downstream to update network infrastructure.
type Drivers ¶
type Drivers struct {
// contains filtered or unexported fields
}
Drivers wraps the map of task-name to associated driver so that the map can be accessed concurrently
func (*Drivers) Delete ¶ added in v0.5.0
Delete removes the driver for the given task name from the map of drivers.
func (*Drivers) GetTaskByTemplate ¶ added in v0.5.0
GetTaskByTemplate retrieves the driver for a task by template ID
func (*Drivers) IsMarkedForDeletion ¶ added in v0.5.0
func (*Drivers) MarkForDeletion ¶ added in v0.5.0
func (*Drivers) SetBufferPeriod ¶ added in v0.1.3
func (d *Drivers) SetBufferPeriod()
func (*Drivers) SetInactive ¶ added in v0.1.3
type InspectPlan ¶
type InspectPlan struct { ChangesPresent bool `json:"changes_present"` Plan string `json:"plan"` URL string `json:"url,omitempty"` }
InspectPlan stores return the information about what
type PatchTask ¶
type PatchTask struct { // RunOption is a set of options on how to handle the patch update // current options are "now" and "inspect". See constants for more details RunOption string Enabled bool }
PatchTask holds the information to patch update a task. It will only include fields that we support updating at this time
type Service ¶
type Service struct { Datacenter string Description string Name string Namespace string Filter string UserDefinedMeta map[string]string }
Service contains service configuration information
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task contains task configuration information
func NewTask ¶ added in v0.2.0
func NewTask(conf TaskConfig) (*Task, error)
func (*Task) BufferPeriod ¶
func (t *Task) BufferPeriod() (BufferPeriod, bool)
BufferPeriod returns a copy of the buffer period. If the buffer period is not configured, the second parameter returns false.
func (*Task) Condition ¶ added in v0.2.0
func (t *Task) Condition() config.ConditionConfig
Condition returns the type of condition for the task to run
func (*Task) DeprecatedTFVersion ¶ added in v0.6.0
DeprecatedTFVersion returns the Terraform version to use when using the Terraform Cloud driver. Enterprise. Deprecated, use the Terraform Version from TFCWorkspace() instead.
func (*Task) Description ¶
Description returns the task description
func (*Task) IsScheduled ¶ added in v0.4.0
IsScheduled returns if the task is a scheduled task or not (a dynamic task)
func (*Task) ModuleInputs ¶ added in v0.5.0
func (t *Task) ModuleInputs() config.ModuleInputConfigs
ModuleInputs returns the type of module input for the task to run
func (*Task) ProviderIDs ¶ added in v0.6.0
ProviderIDs returns the list of providers that the task has configured. The provider id is formatted the same as how providers are configured in a task: If alias provided: <provider-name>.<provider-alias> If alias not provided: <provider-name>
func (*Task) Providers ¶
func (t *Task) Providers() TerraformProviderBlocks
ProviderNames returns the list of providers that the task has configured
func (*Task) ServiceNames ¶
ServiceNames returns the list of services that the task has configured
func (*Task) Services ¶
Services returns a copy of the list of services that the task has configured
func (*Task) TFCWorkspace ¶ added in v0.6.0
func (t *Task) TFCWorkspace() config.TerraformCloudWorkspaceConfig
TFCWorkspace returns the Terraform Cloud Workspace configuration to use for the task when using the Terraform Cloud driver. Enterprise only.
func (*Task) Variables ¶ added in v0.2.0
Variables returns a copy of the loaded input variables for a module from configured variable files.
func (*Task) WorkingDir ¶ added in v0.3.0
WorkingDir returns the working directory to manage generated artifacts for the task.
type TaskConfig ¶ added in v0.2.0
type TaskConfig struct { Description string Name string Enabled bool Env map[string]string Providers TerraformProviderBlocks ProviderInfo map[string]interface{} Services []Service Module string Variables map[string]string Version string BufferPeriod *BufferPeriod Condition config.ConditionConfig ModuleInputs config.ModuleInputConfigs WorkingDir string // Enterprise DeprecatedTFVersion string TFCWorkspace config.TerraformCloudWorkspaceConfig }
type Terraform ¶
type Terraform struct {
// contains filtered or unexported fields
}
Terraform is a CTS driver that uses the Terraform CLI to interface with low-level network infrastructure.
func NewTerraform ¶
func NewTerraform(config *TerraformConfig) (*Terraform, error)
NewTerraform configures and initializes a new Terraform driver for a task. The underlying Terraform CLI client and out-of-band handlers are prepared.
func (*Terraform) DestroyTask ¶ added in v0.5.0
DestroyTask destroys task dependencies so that it is safe for deletion
func (*Terraform) InitTask ¶
InitTask initializes the task by creating the Terraform root module and related files to execute on.
func (*Terraform) InspectTask ¶
func (tf *Terraform) InspectTask(ctx context.Context) (InspectPlan, error)
InspectTask inspects for any differences pertaining to the task between the state of Consul and network infrastructure using the Terraform plan command
func (*Terraform) RenderTemplate ¶
RenderTemplate fetches data for the template. If the data is complete fetched, renders the template. Rendering a template for the first time may take several cycles to load all the dependencies asynchronously. Returns a boolean whether the template was rendered
func (*Terraform) SetBufferPeriod ¶
func (tf *Terraform) SetBufferPeriod()
SetBufferPeriod sets the buffer period for the task. Do not set this when task needs to immediately render a template and run.
func (*Terraform) TemplateIDs ¶ added in v0.5.0
func (*Terraform) UpdateTask ¶
UpdateTask updates the task on the driver. Makes any calls to re-init depending on the fields updated. If update task is requested with the inspect run option, then dry run the updates by returning the inspected plan for the expected updates but do not update the task
type TerraformConfig ¶
type TerraformConfig struct { Task *Task Log bool PersistLog bool Path string Backend map[string]interface{} RequiredProviders map[string]interface{} Watcher templates.Watcher // empty/unknown string will default to TerraformCLI client ClientType string }
TerraformConfig configures the Terraform driver
type TerraformProviderBlock ¶
type TerraformProviderBlock struct {
// contains filtered or unexported fields
}
TerraformProviderBlock contains provider arguments and environment variables for the Terraform provider.
func NewTerraformProviderBlock ¶
func NewTerraformProviderBlock(b hcltmpl.NamedBlock) TerraformProviderBlock
NewTerraformProviderBlock creates a provider block with the environment variables separated from provider arguments from the base hcl block.
func (TerraformProviderBlock) Copy ¶ added in v0.2.0
func (p TerraformProviderBlock) Copy() TerraformProviderBlock
func (TerraformProviderBlock) Env ¶
func (p TerraformProviderBlock) Env() map[string]string
Env returns the configured environment variables for the Terraform provider. These values are set for the task workspace and are not written to any generated Terraform configuration file.
func (TerraformProviderBlock) ID ¶ added in v0.6.0
func (p TerraformProviderBlock) ID() string
ID returns the unique id of the provider. This is the same as nae if no alias is provided. If alias provided, then the id is <provider-name>.<provider-alias>
func (TerraformProviderBlock) Name ¶
func (p TerraformProviderBlock) Name() string
Name returns the name of the provider. This is the label of the HCL named block.
func (TerraformProviderBlock) ProviderBlock ¶
func (p TerraformProviderBlock) ProviderBlock() hcltmpl.NamedBlock
ProviderBlock returns the arguments for the Terraform provider block.
type TerraformProviderBlocks ¶
type TerraformProviderBlocks []TerraformProviderBlock
TerraformProviderBlocks are a list of providers and their arguments and env
func NewTerraformProviderBlocks ¶
func NewTerraformProviderBlocks(blocks []hcltmpl.NamedBlock) TerraformProviderBlocks
NewTerraformProviderBlocks creates a new list of provider blocks with the environment variables separated from provider arguments from the base hcl block.
func (TerraformProviderBlocks) Copy ¶ added in v0.2.0
func (p TerraformProviderBlocks) Copy() TerraformProviderBlocks
func (TerraformProviderBlocks) Env ¶
func (p TerraformProviderBlocks) Env() map[string]string
Env returns a merged map of environment variables across all providers.
func (TerraformProviderBlocks) ProviderBlocks ¶
func (p TerraformProviderBlocks) ProviderBlocks() []hcltmpl.NamedBlock
ProviderBlocks returns a list of the provider blocks.