github.com/ns1/terraform@v0.7.10-0.20161109153551-8949419bef40/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 "artifactory": artifactoryFactory, 40 "atlas": atlasFactory, 41 "azure": azureFactory, 42 "consul": consulFactory, 43 "etcd": etcdFactory, 44 "gcs": gcsFactory, 45 "http": httpFactory, 46 "local": fileFactory, 47 "s3": s3Factory, 48 "swift": swiftFactory, 49 "manta": mantaFactory, 50 }