github.com/tarrant/terraform@v0.3.8-0.20150402012457-f68c9eee638e/state/state.go (about) 1 package state 2 3 import ( 4 "github.com/hashicorp/terraform/terraform" 5 ) 6 7 // State is the collection of all state interfaces. 8 type State interface { 9 StateReader 10 StateWriter 11 StateRefresher 12 StatePersister 13 } 14 15 // StateReader is the interface for things that can return a state. Retrieving 16 // the state here must not error. Loading the state fresh (an operation that 17 // can likely error) should be implemented by RefreshState. If a state hasn't 18 // been loaded yet, it is okay for State to return nil. 19 type StateReader interface { 20 State() *terraform.State 21 } 22 23 // StateWriter is the interface that must be implemented by something that 24 // can write a state. Writing the state can be cached or in-memory, as 25 // full persistence should be implemented by StatePersister. 26 type StateWriter interface { 27 WriteState(*terraform.State) error 28 } 29 30 // StateRefresher is the interface that is implemented by something that 31 // can load a state. This might be refreshing it from a remote location or 32 // it might simply be reloading it from disk. 33 type StateRefresher interface { 34 RefreshState() error 35 } 36 37 // StatePersister is implemented to truly persist a state. Whereas StateWriter 38 // is allowed to perhaps be caching in memory, PersistState must write the 39 // state to some durable storage. 40 type StatePersister interface { 41 PersistState() error 42 }