Documentation
¶
Index ¶
- func ResetInstance()
- type TerraformClient
- func (c *TerraformClient) Apply(ctx context.Context, stage schema.StageConfig) error
- func (c *TerraformClient) Cleanup(ctx context.Context) error
- func (c *TerraformClient) Destroy(ctx context.Context, stage schema.StageConfig) error
- func (c *TerraformClient) Format(ctx context.Context, stage schema.StageConfig) error
- func (c *TerraformClient) Init(ctx context.Context, stage schema.StageConfig, opts TerraformInitOpts) error
- func (c *TerraformClient) Output(ctx context.Context, stage schema.StageConfig) (map[string][]byte, error)
- func (c *TerraformClient) Plan(ctx context.Context, stage schema.StageConfig) (bool, error)
- func (c *TerraformClient) Refresh(ctx context.Context, stage schema.StageConfig) error
- func (c *TerraformClient) Validate(ctx context.Context, stage schema.StageConfig) (*tfjson.ValidateOutput, error)
- func (c *TerraformClient) Version(ctx context.Context) (string, error)
- type TerraformInitOpts
- type TfExecTerraformLogger
- type TfOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResetInstance ¶
func ResetInstance()
ResetInstance resets the singleton instance of the TerraformClient. This is useful for testing to ensure a fresh client is created.
Types ¶
type TerraformClient ¶
type TerraformClient struct {
// contains filtered or unexported fields
}
TerraformClient is a wrapper for the Terraform CLI, providing functionality for managing Terraform operations.
func Instance ¶
func Instance(ctx context.Context, cfg config.Settings) *TerraformClient
Instance returns a singleton instance of the TerraformClient. It initializes the client if it has not been created already.
func NewTerraformClient ¶
NewTerraformClient creates a new TerraformClient instance and ensures the Terraform CLI is available.
func (*TerraformClient) Apply ¶
func (c *TerraformClient) Apply(ctx context.Context, stage schema.StageConfig) error
Apply applies the Terraform configuration for the specified stage. It runs `terraform apply` with the configured input variables.
func (*TerraformClient) Cleanup ¶
func (c *TerraformClient) Cleanup(ctx context.Context) error
Cleanup removes the downloaded Terraform CLI from the file system.
func (*TerraformClient) Destroy ¶
func (c *TerraformClient) Destroy(ctx context.Context, stage schema.StageConfig) error
Destroy destroys the Terraform-managed infrastructure for the specified stage. It runs `terraform destroy` with the configured input variables and targets.
func (*TerraformClient) Format ¶
func (c *TerraformClient) Format(ctx context.Context, stage schema.StageConfig) error
Format formats the Terraform configuration files in the specified stage directory. It runs `terraform fmt -recursive`.
func (*TerraformClient) Init ¶
func (c *TerraformClient) Init(ctx context.Context, stage schema.StageConfig, opts TerraformInitOpts) error
Init initializes the Terraform working directory for the specified stage. It runs `terraform init -upgrade -reconfigure` with the provided backend configuration options.
func (*TerraformClient) Output ¶
func (c *TerraformClient) Output(ctx context.Context, stage schema.StageConfig) (map[string][]byte, error)
Output retrieves the Terraform output for the specified stage directory. It returns a map of output variable names to their values in JSON format.
func (*TerraformClient) Plan ¶
func (c *TerraformClient) Plan(ctx context.Context, stage schema.StageConfig) (bool, error)
Plan creates an execution plan for the specified stage. It runs `terraform plan` with the configured input variables and returns whether changes are required.
func (*TerraformClient) Refresh ¶
func (c *TerraformClient) Refresh(ctx context.Context, stage schema.StageConfig) error
Refresh updates the Terraform state for the specified stage. It runs `terraform refresh` with the configured input variables.
func (*TerraformClient) Validate ¶
func (c *TerraformClient) Validate(ctx context.Context, stage schema.StageConfig) (*tfjson.ValidateOutput, error)
Validate validates the Terraform configuration for the specified stage. It runs `terraform validate` and returns the validation output.
type TerraformInitOpts ¶
type TerraformInitOpts struct {
BackendConfig []string // The backend configuration options.
}
TerraformInitOpts represents options for initializing Terraform with backend configuration.