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