Documentation
¶
Overview ¶
Package container implements container-based IaC module execution. This allows IaC modules (Pulumi, OpenTofu) to be packaged as self-contained container images that include both the IaC code and runtime, eliminating the need for Pulumi/OpenTofu to be installed on the deployment host.
Index ¶
- type BackendConfig
- type BuildOptions
- type BuildResult
- type Builder
- type ExecuteOptions
- type Executor
- type ModuleRequest
- type ModuleResponse
- type ModuleType
- type OutputValue
- type Plugin
- func (p *Plugin) Apply(ctx context.Context, opts iac.RunOptions) (*iac.ApplyResult, error)
- func (p *Plugin) Destroy(ctx context.Context, opts iac.RunOptions) error
- func (p *Plugin) Import(ctx context.Context, opts iac.ImportOptions) (*iac.ImportResult, error)
- func (p *Plugin) Name() string
- func (p *Plugin) Preview(ctx context.Context, opts iac.RunOptions) (*iac.PreviewResult, error)
- func (p *Plugin) Refresh(ctx context.Context, opts iac.RunOptions) (*iac.RefreshResult, error)
- type ResourceChange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackendConfig ¶
type BackendConfig struct {
// Type is the backend type (e.g., "s3", "gcs", "azurerm", "local")
Type string `json:"type"`
// Config contains backend-specific configuration
Config map[string]string `json:"config"`
}
BackendConfig configures state storage for the module.
type BuildOptions ¶
type BuildOptions struct {
// ModuleDir is the directory containing the IaC module
ModuleDir string
// ModuleType is the IaC framework (auto-detected if empty)
ModuleType ModuleType
// Tag is the image tag
Tag string
// Output for build logs
Output io.Writer
}
BuildOptions configures module image building.
type BuildResult ¶
type BuildResult struct {
// Image is the built image tag
Image string
// Digest is the image digest
Digest string
// ModuleType is the detected/specified module type
ModuleType ModuleType
}
BuildResult contains the result of a module build.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder builds container images for IaC modules.
func (*Builder) Build ¶
func (b *Builder) Build(ctx context.Context, opts BuildOptions) (*BuildResult, error)
Build builds a container image for an IaC module.
type ExecuteOptions ¶
type ExecuteOptions struct {
// Image is the container image to run
Image string
// Request is the module request
Request *ModuleRequest
// WorkDir is where to store temporary files
WorkDir string
// Credentials for cloud providers
Credentials map[string]string
// Stdout for streaming output
Stdout io.Writer
// Stderr for streaming errors
Stderr io.Writer
}
ExecuteOptions configures module execution.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor runs containerized IaC modules.
func NewExecutor ¶
NewExecutor creates a new container executor.
func (*Executor) Execute ¶
func (e *Executor) Execute(ctx context.Context, opts ExecuteOptions) (*ModuleResponse, error)
Execute runs a containerized module and returns the response.
type ModuleRequest ¶
type ModuleRequest struct {
// Action is the operation to perform: "preview", "apply", "destroy", "refresh"
Action string `json:"action"`
// Inputs are the module input values
Inputs map[string]interface{} `json:"inputs"`
// State is the current module state (for updates/destroys)
State map[string]interface{} `json:"state,omitempty"`
// Environment variables to set
Environment map[string]string `json:"environment,omitempty"`
// StackName for Pulumi or workspace name for OpenTofu
StackName string `json:"stack_name,omitempty"`
// Backend configuration for state storage
Backend *BackendConfig `json:"backend,omitempty"`
}
ModuleRequest represents the input contract for a containerized module. This is passed to the container via a mounted JSON file.
type ModuleResponse ¶
type ModuleResponse struct {
// Success indicates whether the operation succeeded
Success bool `json:"success"`
// Action that was performed
Action string `json:"action"`
// Outputs from the module (after apply)
Outputs map[string]OutputValue `json:"outputs,omitempty"`
// State to persist (opaque to cldctl)
State map[string]interface{} `json:"state,omitempty"`
// Changes describes what changed (for preview)
Changes []ResourceChange `json:"changes,omitempty"`
// Error message if Success is false
Error string `json:"error,omitempty"`
// Logs from the operation
Logs string `json:"logs,omitempty"`
}
ModuleResponse represents the output contract from a containerized module. The container writes this as JSON to a mounted output file.
type ModuleType ¶
type ModuleType string
ModuleType identifies the IaC framework.
const ( ModuleTypePulumi ModuleType = "pulumi" ModuleTypeOpenTofu ModuleType = "opentofu" )
func DetectModuleType ¶
func DetectModuleType(dir string) (ModuleType, error)
DetectModuleType detects the IaC framework from a module directory.
type OutputValue ¶
type OutputValue struct {
Value interface{} `json:"value"`
Sensitive bool `json:"sensitive,omitempty"`
}
OutputValue represents a module output.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements the IaC plugin interface using containerized modules.
func NewPluginWithType ¶
func NewPluginWithType(moduleType ModuleType) (*Plugin, error)
NewPluginWithType creates a plugin for a specific module type.
func (*Plugin) Apply ¶
func (p *Plugin) Apply(ctx context.Context, opts iac.RunOptions) (*iac.ApplyResult, error)
Apply executes a module to create/update resources.
func (*Plugin) Import ¶
func (p *Plugin) Import(ctx context.Context, opts iac.ImportOptions) (*iac.ImportResult, error)
Import delegates to the containerized module's import entrypoint.
func (*Plugin) Preview ¶
func (p *Plugin) Preview(ctx context.Context, opts iac.RunOptions) (*iac.PreviewResult, error)
Preview shows what changes would be made.
func (*Plugin) Refresh ¶
func (p *Plugin) Refresh(ctx context.Context, opts iac.RunOptions) (*iac.RefreshResult, error)
Refresh reads the current state.
type ResourceChange ¶
type ResourceChange struct {
// Resource identifier
Resource string `json:"resource"`
// Action: create, update, delete, replace, no-op
Action string `json:"action"`
// Before state (for updates/deletes)
Before map[string]interface{} `json:"before,omitempty"`
// After state (for creates/updates)
After map[string]interface{} `json:"after,omitempty"`
}
ResourceChange describes a planned or executed change.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package main implements the cldctl module entrypoint.
|
Package main implements the cldctl module entrypoint. |