Documentation
¶
Index ¶
- func CreateBackendAdapter(config *BackendConfig) (statePkg.Backend, error)
- type Adapter
- func (a *Adapter) Delete(ctx context.Context, key string) error
- func (a *Adapter) Get(ctx context.Context, key string) ([]byte, error)
- func (a *Adapter) GetStateVersion(ctx context.Context, key string, version int) ([]byte, error)
- func (a *Adapter) List(ctx context.Context, prefix string) ([]string, error)
- func (a *Adapter) ListStateVersions(ctx context.Context, key string) ([]statePkg.StateVersion, error)
- func (a *Adapter) ListStates(ctx context.Context) ([]string, error)
- func (a *Adapter) Lock(ctx context.Context, key string) error
- func (a *Adapter) Put(ctx context.Context, key string, data []byte) error
- func (a *Adapter) Unlock(ctx context.Context, key string) error
- type AzureBackend
- func (a *AzureBackend) CreateWorkspace(ctx context.Context, name string) error
- func (a *AzureBackend) DeleteWorkspace(ctx context.Context, name string) error
- func (a *AzureBackend) GetLockInfo(ctx context.Context) (*LockInfo, error)
- func (a *AzureBackend) GetMetadata() *BackendMetadata
- func (a *AzureBackend) GetVersion(ctx context.Context, versionID string) (*StateData, error)
- func (a *AzureBackend) GetVersions(ctx context.Context) ([]*StateVersion, error)
- func (a *AzureBackend) ListWorkspaces(ctx context.Context) ([]string, error)
- func (a *AzureBackend) Lock(ctx context.Context, info *LockInfo) (string, error)
- func (a *AzureBackend) Pull(ctx context.Context) (*StateData, error)
- func (a *AzureBackend) Push(ctx context.Context, state *StateData) error
- func (a *AzureBackend) SelectWorkspace(ctx context.Context, name string) error
- func (a *AzureBackend) Unlock(ctx context.Context, lockID string) error
- func (a *AzureBackend) Validate(ctx context.Context) error
- type Backend
- type BackendConfig
- type BackendFactory
- type BackendMetadata
- type BackendState
- type ConnectionPool
- type LockInfo
- type PoolStats
- type S3Backend
- func (s *S3Backend) CreateWorkspace(ctx context.Context, name string) error
- func (s *S3Backend) DeleteWorkspace(ctx context.Context, name string) error
- func (s *S3Backend) GetLockInfo(ctx context.Context) (*LockInfo, error)
- func (s *S3Backend) GetMetadata() *BackendMetadata
- func (s *S3Backend) GetVersion(ctx context.Context, versionID string) (*StateData, error)
- func (s *S3Backend) GetVersions(ctx context.Context) ([]*StateVersion, error)
- func (s *S3Backend) ListWorkspaces(ctx context.Context) ([]string, error)
- func (s *S3Backend) Lock(ctx context.Context, info *LockInfo) (string, error)
- func (s *S3Backend) Pull(ctx context.Context) (*StateData, error)
- func (s *S3Backend) Push(ctx context.Context, state *StateData) error
- func (s *S3Backend) SelectWorkspace(ctx context.Context, name string) error
- func (s *S3Backend) Unlock(ctx context.Context, lockID string) error
- func (s *S3Backend) Validate(ctx context.Context) error
- type S3ConnectionPool
- type StateData
- type StateResource
- type StateResourceInstance
- type StateVersion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateBackendAdapter ¶
func CreateBackendAdapter(config *BackendConfig) (statePkg.Backend, error)
CreateBackendAdapter creates an adapter for the appropriate backend type
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter bridges the new Backend interface with the legacy state.Backend interface
func NewAdapter ¶
func NewAdapter(backend Backend, config *BackendConfig) *Adapter
NewAdapter creates a new backend adapter
func (*Adapter) GetStateVersion ¶
GetStateVersion retrieves a specific version (legacy interface)
func (*Adapter) ListStateVersions ¶
func (a *Adapter) ListStateVersions(ctx context.Context, key string) ([]statePkg.StateVersion, error)
ListStateVersions returns versions for a state (legacy interface)
func (*Adapter) ListStates ¶
ListStates returns all available states (legacy interface)
type AzureBackend ¶
type AzureBackend struct {
// contains filtered or unexported fields
}
AzureBackend implements the Backend interface for Azure Storage
func NewAzureBackend ¶
func NewAzureBackend(cfg *BackendConfig) (*AzureBackend, error)
NewAzureBackend creates a new Azure Storage backend instance
func (*AzureBackend) CreateWorkspace ¶
func (a *AzureBackend) CreateWorkspace(ctx context.Context, name string) error
CreateWorkspace creates a new workspace
func (*AzureBackend) DeleteWorkspace ¶
func (a *AzureBackend) DeleteWorkspace(ctx context.Context, name string) error
DeleteWorkspace removes a workspace
func (*AzureBackend) GetLockInfo ¶
func (a *AzureBackend) GetLockInfo(ctx context.Context) (*LockInfo, error)
GetLockInfo returns current lock information
func (*AzureBackend) GetMetadata ¶
func (a *AzureBackend) GetMetadata() *BackendMetadata
GetMetadata returns backend metadata
func (*AzureBackend) GetVersion ¶
GetVersion retrieves a specific version of the state
func (*AzureBackend) GetVersions ¶
func (a *AzureBackend) GetVersions(ctx context.Context) ([]*StateVersion, error)
GetVersions returns available state versions using blob snapshots
func (*AzureBackend) ListWorkspaces ¶
func (a *AzureBackend) ListWorkspaces(ctx context.Context) ([]string, error)
ListWorkspaces returns available workspaces
func (*AzureBackend) Pull ¶
func (a *AzureBackend) Pull(ctx context.Context) (*StateData, error)
Pull retrieves the current state from Azure Blob Storage
func (*AzureBackend) Push ¶
func (a *AzureBackend) Push(ctx context.Context, state *StateData) error
Push uploads state to Azure Blob Storage
func (*AzureBackend) SelectWorkspace ¶
func (a *AzureBackend) SelectWorkspace(ctx context.Context, name string) error
SelectWorkspace switches to a different workspace
type Backend ¶
type Backend interface {
// Pull retrieves the current state from the backend
Pull(ctx context.Context) (*StateData, error)
// Push uploads state to the backend
Push(ctx context.Context, state *StateData) error
// Lock acquires a lock on the state for safe operations
Lock(ctx context.Context, info *LockInfo) (string, error)
// Unlock releases the lock on the state
Unlock(ctx context.Context, lockID string) error
// GetVersions returns available state versions/history
GetVersions(ctx context.Context) ([]*StateVersion, error)
// GetVersion retrieves a specific version of the state
GetVersion(ctx context.Context, versionID string) (*StateData, error)
// ListWorkspaces returns available workspaces
ListWorkspaces(ctx context.Context) ([]string, error)
// SelectWorkspace switches to a different workspace
SelectWorkspace(ctx context.Context, name string) error
// CreateWorkspace creates a new workspace
CreateWorkspace(ctx context.Context, name string) error
// DeleteWorkspace removes a workspace
DeleteWorkspace(ctx context.Context, name string) error
// GetLockInfo returns current lock information
GetLockInfo(ctx context.Context) (*LockInfo, error)
// Validate checks if the backend is properly configured and accessible
Validate(ctx context.Context) error
// GetMetadata returns backend metadata
GetMetadata() *BackendMetadata
}
Backend defines the interface for state backend operations
type BackendConfig ¶
type BackendConfig struct {
Type string `json:"type"`
Config map[string]interface{} `json:"config"`
// Connection pool settings
MaxConnections int `json:"max_connections,omitempty"`
MaxIdleConnections int `json:"max_idle_connections,omitempty"`
ConnectionTimeout time.Duration `json:"connection_timeout,omitempty"`
IdleTimeout time.Duration `json:"idle_timeout,omitempty"`
// Retry settings
MaxRetries int `json:"max_retries,omitempty"`
RetryDelay time.Duration `json:"retry_delay,omitempty"`
RetryBackoff float64 `json:"retry_backoff,omitempty"`
// Lock settings
LockTimeout time.Duration `json:"lock_timeout,omitempty"`
LockRetryDelay time.Duration `json:"lock_retry_delay,omitempty"`
}
BackendConfig represents backend configuration
type BackendFactory ¶
type BackendFactory interface {
// CreateBackend creates a backend instance from configuration
CreateBackend(config *BackendConfig) (Backend, error)
// GetSupportedTypes returns list of supported backend types
GetSupportedTypes() []string
// ValidateConfig validates backend configuration
ValidateConfig(config *BackendConfig) error
}
BackendFactory creates backend instances based on configuration
type BackendMetadata ¶
type BackendMetadata struct {
Type string `json:"type"`
SupportsLocking bool `json:"supports_locking"`
SupportsVersions bool `json:"supports_versions"`
SupportsWorkspaces bool `json:"supports_workspaces"`
Configuration map[string]string `json:"configuration"`
Workspace string `json:"workspace"`
StateKey string `json:"state_key"`
LockTable string `json:"lock_table,omitempty"`
}
BackendMetadata contains metadata about the backend
type BackendState ¶
type BackendState struct {
Type string `json:"type"`
Config map[string]interface{} `json:"config"`
Hash string `json:"hash"`
Workspace string `json:"workspace,omitempty"`
}
BackendState represents the backend configuration in state
type ConnectionPool ¶
type ConnectionPool interface {
// Get retrieves a connection from the pool
Get(ctx context.Context) (io.Closer, error)
// Put returns a connection to the pool
Put(conn io.Closer)
// Close closes all connections in the pool
Close() error
// Stats returns pool statistics
Stats() *PoolStats
}
ConnectionPool manages backend connections
type LockInfo ¶
type LockInfo struct {
ID string `json:"ID"`
Path string `json:"Path"`
Operation string `json:"Operation"`
Who string `json:"Who"`
Version string `json:"Version"`
Created time.Time `json:"Created"`
Info string `json:"Info"`
}
LockInfo represents state lock information
type PoolStats ¶
type PoolStats struct {
Active int `json:"active"`
Idle int `json:"idle"`
MaxOpen int `json:"max_open"`
MaxIdle int `json:"max_idle"`
WaitCount int64 `json:"wait_count"`
WaitDuration time.Duration `json:"wait_duration"`
IdleTimeout time.Duration `json:"idle_timeout"`
Created int64 `json:"created"`
Closed int64 `json:"closed"`
}
PoolStats contains connection pool statistics
type S3Backend ¶
type S3Backend struct {
// contains filtered or unexported fields
}
S3Backend implements the Backend interface for AWS S3
func NewS3Backend ¶
func NewS3Backend(cfg *BackendConfig) (*S3Backend, error)
NewS3Backend creates a new S3 backend instance
func (*S3Backend) CreateWorkspace ¶
CreateWorkspace creates a new workspace
func (*S3Backend) DeleteWorkspace ¶
DeleteWorkspace removes a workspace
func (*S3Backend) GetLockInfo ¶
GetLockInfo returns current lock information
func (*S3Backend) GetMetadata ¶
func (s *S3Backend) GetMetadata() *BackendMetadata
GetMetadata returns backend metadata
func (*S3Backend) GetVersion ¶
GetVersion retrieves a specific version of the state
func (*S3Backend) GetVersions ¶
func (s *S3Backend) GetVersions(ctx context.Context) ([]*StateVersion, error)
GetVersions returns available state versions using S3 versioning
func (*S3Backend) ListWorkspaces ¶
ListWorkspaces returns available workspaces
func (*S3Backend) SelectWorkspace ¶
SelectWorkspace switches to a different workspace
type S3ConnectionPool ¶
type S3ConnectionPool struct {
// contains filtered or unexported fields
}
S3ConnectionPool manages S3 client connections
func NewS3ConnectionPool ¶
func NewS3ConnectionPool(maxOpen, maxIdle int, idleTimeout time.Duration) *S3ConnectionPool
NewS3ConnectionPool creates a new connection pool
type StateData ¶
type StateData struct {
Version int `json:"version"`
TerraformVersion string `json:"terraform_version"`
Serial uint64 `json:"serial"`
Lineage string `json:"lineage"`
Data []byte `json:"-"`
Resources []StateResource `json:"resources,omitempty"`
Outputs map[string]interface{} `json:"outputs,omitempty"`
Backend *BackendState `json:"backend,omitempty"`
Checksum string `json:"checksum,omitempty"`
LastModified time.Time `json:"last_modified"`
Size int64 `json:"size"`
}
StateData represents Terraform state data
type StateResource ¶
type StateResource struct {
Mode string `json:"mode"`
Type string `json:"type"`
Name string `json:"name"`
Provider string `json:"provider"`
Instances []StateResourceInstance `json:"instances"`
}
StateResource represents a resource in the state
type StateResourceInstance ¶
type StateResourceInstance struct {
SchemaVersion int `json:"schema_version"`
Attributes map[string]interface{} `json:"attributes"`
Dependencies []string `json:"dependencies,omitempty"`
CreateBeforeDestroy bool `json:"create_before_destroy,omitempty"`
}
StateResourceInstance represents an instance of a resource
type StateVersion ¶
type StateVersion struct {
ID string `json:"id"`
VersionID string `json:"version_id"`
Serial uint64 `json:"serial"`
Created time.Time `json:"created"`
CreatedBy string `json:"created_by,omitempty"`
Size int64 `json:"size"`
Checksum string `json:"checksum,omitempty"`
IsLatest bool `json:"is_latest"`
Description string `json:"description,omitempty"`
}
StateVersion represents a version of the state