github.com/aznashwan/terraform@v0.4.3-0.20151118032030-21f93ca4558d/state/remote/remote.go (about) 1 package remote 2 3 import ( 4 "fmt" 5 ) 6 7 // Client is the interface that must be implemented for a remote state 8 // driver. It supports dumb put/get/delete, and the higher level structs 9 // handle persisting the state properly here. 10 type Client interface { 11 Get() (*Payload, error) 12 Put([]byte) error 13 Delete() error 14 } 15 16 // Payload is the return value from the remote state storage. 17 type Payload struct { 18 MD5 []byte 19 Data []byte 20 } 21 22 // Factory is the factory function to create a remote client. 23 type Factory func(map[string]string) (Client, error) 24 25 // NewClient returns a new Client with the given type and configuration. 26 // The client is looked up in the BuiltinClients variable. 27 func NewClient(t string, conf map[string]string) (Client, error) { 28 f, ok := BuiltinClients[t] 29 if !ok { 30 return nil, fmt.Errorf("unknown remote client type: %s", t) 31 } 32 33 return f(conf) 34 } 35 36 // BuiltinClients is the list of built-in clients that can be used with 37 // NewClient. 38 var BuiltinClients = map[string]Factory{ 39 "atlas": atlasFactory, 40 "consul": consulFactory, 41 "etcd": etcdFactory, 42 "http": httpFactory, 43 "s3": s3Factory, 44 "swift": swiftFactory, 45 46 // This is used for development purposes only. 47 "_local": fileFactory, 48 }