Documentation ¶
Index ¶
- func TestState(t *testing.T, s interface{})
- func TestStateInitial() *terraform.State
- type BackupState
- func (s *BackupState) Lock(info *LockInfo) (string, error)
- func (s *BackupState) PersistState() error
- func (s *BackupState) RefreshState() error
- func (s *BackupState) State() *terraform.State
- func (s *BackupState) Unlock(id string) error
- func (s *BackupState) WriteState(state *terraform.State) error
- type InmemState
- type LocalState
- func (s *LocalState) Lock(info *LockInfo) (string, error)
- func (s *LocalState) PersistState() error
- func (s *LocalState) RefreshState() error
- func (s *LocalState) SetState(state *terraform.State)
- func (s *LocalState) State() *terraform.State
- func (s *LocalState) Unlock(id string) error
- func (s *LocalState) WriteState(state *terraform.State) error
- type LockError
- type LockInfo
- type Locker
- type State
- type StatePersister
- type StateReader
- type StateRefresher
- type StateWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestState ¶
TestState is a helper for testing state implementations. It is expected that the given implementation is pre-loaded with the TestStateInitial state.
func TestStateInitial ¶
TestStateInitial is the initial state that a State should have for TestState.
Types ¶
type BackupState ¶
BackupState wraps a State that backs up the state on the first time that a WriteState or PersistState is called.
If Path exists, it will be overwritten.
func (*BackupState) Lock ¶
func (s *BackupState) Lock(info *LockInfo) (string, error)
all states get wrapped by BackupState, so it has to be a Locker
func (*BackupState) PersistState ¶
func (s *BackupState) PersistState() error
func (*BackupState) RefreshState ¶
func (s *BackupState) RefreshState() error
func (*BackupState) State ¶
func (s *BackupState) State() *terraform.State
func (*BackupState) Unlock ¶
func (s *BackupState) Unlock(id string) error
func (*BackupState) WriteState ¶
func (s *BackupState) WriteState(state *terraform.State) error
type InmemState ¶
type InmemState struct {
// contains filtered or unexported fields
}
InmemState is an in-memory state storage.
func (*InmemState) PersistState ¶
func (s *InmemState) PersistState() error
func (*InmemState) RefreshState ¶
func (s *InmemState) RefreshState() error
func (*InmemState) State ¶
func (s *InmemState) State() *terraform.State
func (*InmemState) WriteState ¶
func (s *InmemState) WriteState(state *terraform.State) error
type LocalState ¶
type LocalState struct { // Path is the path to read the state from. PathOut is the path to // write the state to. If PathOut is not specified, Path will be used. // If PathOut already exists, it will be overwritten. Path string PathOut string // contains filtered or unexported fields }
LocalState manages a state storage that is local to the filesystem.
func (*LocalState) Lock ¶
func (s *LocalState) Lock(info *LockInfo) (string, error)
Lock implements a local filesystem state.Locker.
func (*LocalState) PersistState ¶
func (s *LocalState) PersistState() error
PersistState for LocalState is a no-op since WriteState always persists.
StatePersister impl.
func (*LocalState) SetState ¶
func (s *LocalState) SetState(state *terraform.State)
SetState will force a specific state in-memory for this local state.
func (*LocalState) Unlock ¶
func (s *LocalState) Unlock(id string) error
func (*LocalState) WriteState ¶
func (s *LocalState) WriteState(state *terraform.State) error
WriteState for LocalState always persists the state as well. TODO: this should use a more robust method of writing state, by first writing to a temp file on the same filesystem, and renaming the file over the original.
StateWriter impl.
type LockInfo ¶
type LockInfo struct { // Unique ID for the lock. NewLockInfo provides a random ID, but this may // be overridden by the lock implementation. The final value if ID will be // returned by the call to Lock. ID string // Terraform operation, provided by the caller. Operation string // Extra information to store with the lock, provided by the caller. Info string // user@hostname when available Who string // Terraform version Version string // Time that the lock was taken. Created time.Time // Path to the state file when applicable. Set by the Lock implementation. Path string }
LockInfo stores lock metadata.
Only Operation and Info are required to be set by the caller of Lock.
func NewLockInfo ¶
func NewLockInfo() *LockInfo
Generate a LockInfo structure, populating the required fields.
type Locker ¶
Locker is implemented to lock state during command execution. The info parameter can be recorded with the lock, but the implementation should not depend in its value. The string returned by Lock is an ID corresponding to the lock acquired, and must be passed to Unlock to ensure that the correct lock is being released.
Lock and Unlock may return an error value of type LockError which in turn can contain the LockInfo of a conflicting lock.
type State ¶
type State interface { StateReader StateWriter StateRefresher StatePersister }
State is the collection of all state interfaces.
type StatePersister ¶
type StatePersister interface {
PersistState() error
}
StatePersister is implemented to truly persist a state. Whereas StateWriter is allowed to perhaps be caching in memory, PersistState must write the state to some durable storage.
type StateReader ¶
StateReader is the interface for things that can return a state. Retrieving the state here must not error. Loading the state fresh (an operation that can likely error) should be implemented by RefreshState. If a state hasn't been loaded yet, it is okay for State to return nil.
type StateRefresher ¶
type StateRefresher interface {
RefreshState() error
}
StateRefresher is the interface that is implemented by something that can load a state. This might be refreshing it from a remote location or it might simply be reloading it from disk.
type StateWriter ¶
StateWriter is the interface that must be implemented by something that can write a state. Writing the state can be cached or in-memory, as full persistence should be implemented by StatePersister.