Documentation
¶
Index ¶
- type Backend
- type BackupManager
- func (bm *BackupManager) CreateBackup(backupID string, state interface{}) error
- func (bm *BackupManager) DeleteBackup(backupID string) error
- func (bm *BackupManager) ListBackups() ([]*BackupMetadata, error)
- func (bm *BackupManager) LoadMetadata() error
- func (bm *BackupManager) RestoreBackup(backupID string) error
- func (bm *BackupManager) SaveMetadata() error
- func (bm *BackupManager) SetCompression(enabled bool)
- func (bm *BackupManager) SetEncryption(enabled bool, key []byte)
- func (bm *BackupManager) SetMaxBackups(max int)
- type BackupMetadata
- type BackupOptions
- type CacheItem
- type CacheStats
- type CheckObject
- type CheckResult
- type Instance
- type LocalBackend
- func (lb *LocalBackend) Delete(ctx context.Context, key string) error
- func (lb *LocalBackend) Get(ctx context.Context, key string) ([]byte, error)
- func (lb *LocalBackend) GetStateVersion(ctx context.Context, key string, version int) ([]byte, error)
- func (lb *LocalBackend) List(ctx context.Context, prefix string) ([]string, error)
- func (lb *LocalBackend) ListStateVersions(ctx context.Context, key string) ([]StateVersion, error)
- func (lb *LocalBackend) ListStates(ctx context.Context) ([]string, error)
- func (lb *LocalBackend) Lock(ctx context.Context, key string) error
- func (lb *LocalBackend) Put(ctx context.Context, key string, data []byte) error
- func (lb *LocalBackend) Unlock(ctx context.Context, key string) error
- type Module
- type OutputValue
- type Parser
- func (p *Parser) ExtractProviders(state *TerraformState) []string
- func (p *Parser) GetResourceByAddress(state *TerraformState, address string) (*Resource, *Instance, error)
- func (p *Parser) GetResourceCount(state *TerraformState) int
- func (p *Parser) GetResourcesByProvider(state *TerraformState, provider string) []Resource
- func (p *Parser) GetResourcesByType(state *TerraformState, resourceType string) []Resource
- func (p *Parser) MergeStates(states ...*TerraformState) (*TerraformState, error)
- func (p *Parser) Parse(data []byte) (*TerraformState, error)
- func (p *Parser) ParseLegacy(data []byte) (*TerraformState, error)
- func (p *Parser) ValidateState(state *TerraformState) error
- type Resource
- type Severity
- type State
- type StateCache
- func (c *StateCache) Clear()
- func (c *StateCache) Delete(key string)
- func (c *StateCache) Get(key string) *TerraformState
- func (c *StateCache) GetKeys() []string
- func (c *StateCache) GetStats() CacheStats
- func (c *StateCache) Has(key string) bool
- func (c *StateCache) Set(key string, state *TerraformState)
- func (c *StateCache) SetMaxSize(size int)
- func (c *StateCache) SetTTL(ttl time.Duration)
- func (c *StateCache) Size() int
- func (c *StateCache) Touch(key string)
- type StateDifference
- type StateFile
- type StateManager
- func (sm *StateManager) CompareStates(ctx context.Context, key1, key2 string) ([]StateDifference, error)
- func (sm *StateManager) DeleteState(ctx context.Context, key string) error
- func (sm *StateManager) GetState(ctx context.Context, key string) (*TerraformState, error)
- func (sm *StateManager) GetStateHistory(ctx context.Context, key string) ([]StateVersion, error)
- func (sm *StateManager) GetStateMetadata(ctx context.Context, key string) (*StateMetadata, error)
- func (sm *StateManager) ImportResource(ctx context.Context, key string, resource Resource) error
- func (sm *StateManager) ListStates(ctx context.Context) ([]string, error)
- func (sm *StateManager) MoveResource(ctx context.Context, key string, fromAddress, toAddress string) error
- func (sm *StateManager) RefreshState(ctx context.Context, key string, actualResources map[string]interface{}) error
- func (sm *StateManager) RemoveResource(ctx context.Context, key string, resourceAddress string) error
- func (sm *StateManager) RestoreStateVersion(ctx context.Context, key string, version int) error
- func (sm *StateManager) UpdateState(ctx context.Context, key string, state *TerraformState) error
- type StateMetadata
- type StateParser
- type StateVersion
- type TerraformState
- type ValidationError
- type ValidationResult
- type ValidationRule
- type Validator
- func (v *Validator) AddRule(rule ValidationRule)
- func (v *Validator) ClearRules()
- func (v *Validator) GetRules() []ValidationRule
- func (v *Validator) RemoveRule(name string)
- func (v *Validator) SetStrictMode(strict bool)
- func (v *Validator) Validate(state *TerraformState) error
- func (v *Validator) ValidateJSON(data []byte) error
- func (v *Validator) ValidateResourceAddress(address string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
Get(ctx context.Context, key string) ([]byte, error)
Put(ctx context.Context, key string, data []byte) error
Delete(ctx context.Context, key string) error
List(ctx context.Context, prefix string) ([]string, error)
Lock(ctx context.Context, key string) error
Unlock(ctx context.Context, key string) error
ListStates(ctx context.Context) ([]string, error)
ListStateVersions(ctx context.Context, key string) ([]StateVersion, error)
GetStateVersion(ctx context.Context, key string, version int) ([]byte, error)
}
Backend interface for state storage backends
func NewLocalBackend ¶
NewLocalBackend creates a new local file backend
type BackupManager ¶
type BackupManager struct {
// contains filtered or unexported fields
}
func NewBackupManager ¶
func NewBackupManager(backupDir string) *BackupManager
func (*BackupManager) CreateBackup ¶
func (bm *BackupManager) CreateBackup(backupID string, state interface{}) error
func (*BackupManager) DeleteBackup ¶
func (bm *BackupManager) DeleteBackup(backupID string) error
func (*BackupManager) ListBackups ¶
func (bm *BackupManager) ListBackups() ([]*BackupMetadata, error)
func (*BackupManager) LoadMetadata ¶
func (bm *BackupManager) LoadMetadata() error
func (*BackupManager) RestoreBackup ¶
func (bm *BackupManager) RestoreBackup(backupID string) error
func (*BackupManager) SaveMetadata ¶
func (bm *BackupManager) SaveMetadata() error
func (*BackupManager) SetCompression ¶
func (bm *BackupManager) SetCompression(enabled bool)
func (*BackupManager) SetEncryption ¶
func (bm *BackupManager) SetEncryption(enabled bool, key []byte)
func (*BackupManager) SetMaxBackups ¶
func (bm *BackupManager) SetMaxBackups(max int)
type BackupMetadata ¶
type BackupMetadata struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
Size int64 `json:"size"`
Compressed bool `json:"compressed"`
Encrypted bool `json:"encrypted"`
StateVersion int `json:"state_version"`
Description string `json:"description"`
Tags map[string]string `json:"tags"`
}
type BackupOptions ¶
type CacheStats ¶
type CacheStats struct {
ItemCount int `json:"item_count"`
TotalSize int64 `json:"total_size"`
OldestItem time.Time `json:"oldest_item"`
NewestItem time.Time `json:"newest_item"`
}
CacheStats contains cache statistics
type CheckObject ¶
CheckObject represents an object in a check result
type CheckResult ¶
type CheckResult struct {
ObjectKind string `json:"object_kind"`
ConfigAddr string `json:"config_addr"`
Status string `json:"status"`
Objects []CheckObject `json:"objects,omitempty"`
}
CheckResult represents a check result in the state
type Instance ¶
type Instance struct {
SchemaVersion int `json:"schema_version"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
AttributesFlat map[string]string `json:"attributes_flat,omitempty"`
SensitiveAttributes []string `json:"sensitive_attributes,omitempty"`
Private string `json:"private,omitempty"`
Dependencies []string `json:"dependencies,omitempty"`
CreateBeforeDestroy bool `json:"create_before_destroy,omitempty"`
IndexKey interface{} `json:"index_key,omitempty"`
Status string `json:"status,omitempty"`
StatusReason string `json:"status_reason,omitempty"`
}
Instance represents an instance of a resource
type LocalBackend ¶
type LocalBackend struct {
// contains filtered or unexported fields
}
LocalBackend implements Backend interface for local file storage
func (*LocalBackend) Delete ¶
func (lb *LocalBackend) Delete(ctx context.Context, key string) error
Delete removes data for a key
func (*LocalBackend) GetStateVersion ¶
func (lb *LocalBackend) GetStateVersion(ctx context.Context, key string, version int) ([]byte, error)
GetStateVersion retrieves a specific version of a state
func (*LocalBackend) ListStateVersions ¶
func (lb *LocalBackend) ListStateVersions(ctx context.Context, key string) ([]StateVersion, error)
ListStateVersions returns versions of a state
func (*LocalBackend) ListStates ¶
func (lb *LocalBackend) ListStates(ctx context.Context) ([]string, error)
ListStates returns all state keys
func (*LocalBackend) Lock ¶
func (lb *LocalBackend) Lock(ctx context.Context, key string) error
Lock acquires a lock for a key
type Module ¶
type Module struct {
Path []string `json:"path"`
Outputs map[string]OutputValue `json:"outputs,omitempty"`
Resources map[string]Resource `json:"resources,omitempty"`
}
Module represents a module in the state
type OutputValue ¶
type OutputValue struct {
Value interface{} `json:"value"`
Type interface{} `json:"type,omitempty"`
Sensitive bool `json:"sensitive,omitempty"`
}
OutputValue represents an output value in the state
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser handles parsing of Terraform state files
func (*Parser) ExtractProviders ¶
func (p *Parser) ExtractProviders(state *TerraformState) []string
ExtractProviders extracts unique providers from the state
func (*Parser) GetResourceByAddress ¶
func (p *Parser) GetResourceByAddress(state *TerraformState, address string) (*Resource, *Instance, error)
GetResourceByAddress returns a resource by its address
func (*Parser) GetResourceCount ¶
func (p *Parser) GetResourceCount(state *TerraformState) int
GetResourceCount returns the total number of resource instances
func (*Parser) GetResourcesByProvider ¶
func (p *Parser) GetResourcesByProvider(state *TerraformState, provider string) []Resource
GetResourcesByProvider returns all resources for a specific provider
func (*Parser) GetResourcesByType ¶
func (p *Parser) GetResourcesByType(state *TerraformState, resourceType string) []Resource
GetResourcesByType returns all resources of a specific type
func (*Parser) MergeStates ¶
func (p *Parser) MergeStates(states ...*TerraformState) (*TerraformState, error)
MergeStates merges multiple state files into one
func (*Parser) Parse ¶
func (p *Parser) Parse(data []byte) (*TerraformState, error)
Parse parses raw state data into a TerraformState structure
func (*Parser) ParseLegacy ¶
func (p *Parser) ParseLegacy(data []byte) (*TerraformState, error)
ParseLegacy parses legacy Terraform state formats (< 0.11)
func (*Parser) ValidateState ¶
func (p *Parser) ValidateState(state *TerraformState) error
ValidateState performs basic validation on the state
type Resource ¶
type Resource struct {
ID string `json:"id,omitempty"`
Module string `json:"module,omitempty"`
Mode string `json:"mode"`
Type string `json:"type"`
Name string `json:"name"`
Provider string `json:"provider"`
Instances []Instance `json:"instances"`
DependsOn []string `json:"depends_on,omitempty"`
EachMode string `json:"each,omitempty"`
}
Resource represents a resource in the state
type StateCache ¶
type StateCache struct {
// contains filtered or unexported fields
}
StateCache provides caching for parsed Terraform states
func NewStateCache ¶
func NewStateCache(ttl time.Duration) *StateCache
NewStateCache creates a new state cache
func (*StateCache) Delete ¶
func (c *StateCache) Delete(key string)
Delete removes a state from the cache
func (*StateCache) Get ¶
func (c *StateCache) Get(key string) *TerraformState
Get retrieves a state from the cache
func (*StateCache) GetStats ¶
func (c *StateCache) GetStats() CacheStats
GetStats returns cache statistics
func (*StateCache) Has ¶
func (c *StateCache) Has(key string) bool
Has checks if a key exists in the cache
func (*StateCache) Set ¶
func (c *StateCache) Set(key string, state *TerraformState)
Set stores a state in the cache
func (*StateCache) SetMaxSize ¶
func (c *StateCache) SetMaxSize(size int)
SetMaxSize updates the maximum cache size
func (*StateCache) SetTTL ¶
func (c *StateCache) SetTTL(ttl time.Duration)
SetTTL updates the TTL for the cache
func (*StateCache) Size ¶
func (c *StateCache) Size() int
Size returns the number of items in the cache
func (*StateCache) Touch ¶
func (c *StateCache) Touch(key string)
Touch updates the access time of a cached item
type StateDifference ¶
type StateDifference struct {
Type string `json:"type"` // added, removed, modified
Resource string `json:"resource"`
OldValue interface{} `json:"old_value,omitempty"`
NewValue interface{} `json:"new_value,omitempty"`
Description string `json:"description"`
}
StateDifference represents a difference between two states
type StateFile ¶
type StateFile struct {
*TerraformState
Path string `json:"path,omitempty"`
}
StateFile represents a Terraform state file
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager manages Terraform state operations
func NewStateManager ¶
func NewStateManager(backend Backend) *StateManager
NewStateManager creates a new state manager
func (*StateManager) CompareStates ¶
func (sm *StateManager) CompareStates(ctx context.Context, key1, key2 string) ([]StateDifference, error)
CompareStates compares two states and returns differences
func (*StateManager) DeleteState ¶
func (sm *StateManager) DeleteState(ctx context.Context, key string) error
DeleteState removes a state file
func (*StateManager) GetState ¶
func (sm *StateManager) GetState(ctx context.Context, key string) (*TerraformState, error)
GetState retrieves and parses a state file
func (*StateManager) GetStateHistory ¶
func (sm *StateManager) GetStateHistory(ctx context.Context, key string) ([]StateVersion, error)
GetStateHistory retrieves the version history of a state
func (*StateManager) GetStateMetadata ¶
func (sm *StateManager) GetStateMetadata(ctx context.Context, key string) (*StateMetadata, error)
GetStateMetadata retrieves metadata about a state without parsing the full state
func (*StateManager) ImportResource ¶
ImportResource adds a new resource to the state
func (*StateManager) ListStates ¶
func (sm *StateManager) ListStates(ctx context.Context) ([]string, error)
ListStates lists all available states
func (*StateManager) MoveResource ¶
func (sm *StateManager) MoveResource(ctx context.Context, key string, fromAddress, toAddress string) error
MoveResource moves a resource within the state
func (*StateManager) RefreshState ¶
func (sm *StateManager) RefreshState(ctx context.Context, key string, actualResources map[string]interface{}) error
RefreshState updates the state with actual cloud resource data
func (*StateManager) RemoveResource ¶
func (sm *StateManager) RemoveResource(ctx context.Context, key string, resourceAddress string) error
RemoveResource removes a resource from the state
func (*StateManager) RestoreStateVersion ¶
RestoreStateVersion restores a specific version of a state
func (*StateManager) UpdateState ¶
func (sm *StateManager) UpdateState(ctx context.Context, key string, state *TerraformState) error
UpdateState updates a state file
type StateMetadata ¶
type StateMetadata struct {
Key string `json:"key"`
Version int `json:"version"`
Serial int `json:"serial"`
Lineage string `json:"lineage"`
LastModified time.Time `json:"last_modified"`
Size int64 `json:"size"`
Checksum string `json:"checksum"`
ResourceCount int `json:"resource_count"`
}
StateMetadata contains metadata about a state
type StateParser ¶
type StateParser struct{}
StateParser handles parsing of Terraform state files
type StateVersion ¶
type StateVersion struct {
Version int `json:"version"`
Serial int `json:"serial"`
Timestamp time.Time `json:"timestamp"`
Checksum string `json:"checksum"`
}
StateVersion represents a version of a state file
type TerraformState ¶
type TerraformState struct {
Version int `json:"version"`
TerraformVersion string `json:"terraform_version"`
Serial int `json:"serial"`
Lineage string `json:"lineage"`
Outputs map[string]OutputValue `json:"outputs,omitempty"`
Resources []Resource `json:"resources"`
CheckResults []CheckResult `json:"check_results,omitempty"`
Modules []Module `json:"modules,omitempty"`
}
TerraformState represents a complete Terraform state file
type ValidationError ¶
type ValidationError struct {
Rule string `json:"rule"`
Message string `json:"message"`
Severity Severity `json:"severity"`
Resource string `json:"resource,omitempty"`
Field string `json:"field,omitempty"`
}
ValidationError represents a validation error
type ValidationResult ¶
type ValidationResult struct {
Valid bool
Errors []ValidationError
Warnings []ValidationError
}
ValidationResult contains the results of validation
type ValidationRule ¶
type ValidationRule struct {
Name string
Description string
Validate func(*TerraformState) error
Severity Severity
}
ValidationRule defines a validation rule
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates Terraform state files
func (*Validator) AddRule ¶
func (v *Validator) AddRule(rule ValidationRule)
AddRule adds a custom validation rule
func (*Validator) ClearRules ¶
func (v *Validator) ClearRules()
ClearRules removes all validation rules
func (*Validator) GetRules ¶
func (v *Validator) GetRules() []ValidationRule
GetRules returns all validation rules
func (*Validator) RemoveRule ¶
RemoveRule removes a validation rule by name
func (*Validator) SetStrictMode ¶
SetStrictMode enables or disables strict validation mode
func (*Validator) Validate ¶
func (v *Validator) Validate(state *TerraformState) error
Validate validates a Terraform state
func (*Validator) ValidateJSON ¶
ValidateJSON validates that state data is valid JSON
func (*Validator) ValidateResourceAddress ¶
ValidateResourceAddress validates a resource address format