mirror of https://github.com/docker/docs.git
store: Mock stores can now be created
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
b459f7c7f8
commit
f49ca7e20f
|
@ -6,15 +6,17 @@ import "github.com/stretchr/testify/mock"
|
||||||
type Mock struct {
|
type Mock struct {
|
||||||
mock.Mock
|
mock.Mock
|
||||||
|
|
||||||
endpoints []string
|
// Endpoints passed to InitializeMock
|
||||||
options *Config
|
Endpoints []string
|
||||||
|
// Options passed to InitializeMock
|
||||||
|
Options *Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitializeMock creates a Mock store.
|
// InitializeMock creates a Mock store.
|
||||||
func InitializeMock(endpoints []string, options *Config) (Store, error) {
|
func InitializeMock(endpoints []string, options *Config) (Store, error) {
|
||||||
s := &Mock{}
|
s := &Mock{}
|
||||||
s.endpoints = endpoints
|
s.Endpoints = endpoints
|
||||||
s.options = options
|
s.Options = options
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,10 @@ import (
|
||||||
type Backend string
|
type Backend string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// MOCK backend
|
||||||
|
MOCK Backend = "mock"
|
||||||
// CONSUL backend
|
// CONSUL backend
|
||||||
CONSUL Backend = "consul"
|
CONSUL = "consul"
|
||||||
// ETCD backend
|
// ETCD backend
|
||||||
ETCD = "etcd"
|
ETCD = "etcd"
|
||||||
// ZK backend
|
// ZK backend
|
||||||
|
@ -114,6 +116,7 @@ type Initialize func(addrs []string, options *Config) (Store, error)
|
||||||
var (
|
var (
|
||||||
// Backend initializers
|
// Backend initializers
|
||||||
initializers = map[Backend]Initialize{
|
initializers = map[Backend]Initialize{
|
||||||
|
MOCK: InitializeMock,
|
||||||
CONSUL: InitializeConsul,
|
CONSUL: InitializeConsul,
|
||||||
ETCD: InitializeEtcd,
|
ETCD: InitializeEtcd,
|
||||||
ZK: InitializeZookeeper,
|
ZK: InitializeZookeeper,
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Zookeeper embeds the zookeeper client
|
// Zookeeper embeds the zookeeper client
|
||||||
// and list of watches
|
|
||||||
type Zookeeper struct {
|
type Zookeeper struct {
|
||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
client *zk.Conn
|
client *zk.Conn
|
||||||
|
|
Loading…
Reference in New Issue