Merge pull request #701 from denverdino/master

Fix the issue for the --cluster-store URL with path
This commit is contained in:
Jana Radhakrishnan 2015-10-26 12:05:21 -07:00
commit ed9d4d890a
3 changed files with 23 additions and 6 deletions

View File

@ -133,7 +133,7 @@ func makeDefaultScopes() map[string]*ScopeCfg {
def := make(map[string]*ScopeCfg)
def[LocalScope] = &ScopeCfg{
Client: ScopeClientCfg{
Provider: "boltdb",
Provider: string(store.BOLTDB),
Address: defaultPrefix + "/local-kv.db",
Config: &store.Config{
Bucket: "libnetwork",
@ -144,7 +144,8 @@ func makeDefaultScopes() map[string]*ScopeCfg {
return def
}
var rootChain = []string{"docker", "network", "v1.0"}
var defaultRootChain = []string{"docker", "network", "v1.0"}
var rootChain = defaultRootChain
func init() {
consul.Register()
@ -195,6 +196,7 @@ func ParseKey(key string) ([]string, error) {
// newClient used to connect to KV Store
func newClient(scope string, kv string, addr string, config *store.Config, cached bool) (DataStore, error) {
if cached && scope != LocalScope {
return nil, fmt.Errorf("caching supported only for scope %s", LocalScope)
}
@ -203,7 +205,21 @@ func newClient(scope string, kv string, addr string, config *store.Config, cache
config = &store.Config{}
}
addrs := strings.Split(addr, ",")
var addrs []string
if kv == string(store.BOLTDB) {
// Parse file path
addrs = strings.Split(addr, ",")
} else {
// Parse URI
parts := strings.SplitN(addr, "/", 2)
addrs = strings.Split(parts[0], ",")
// Add the custom prefix to the root chain
if len(parts) == 2 {
rootChain = append([]string{parts[1]}, defaultRootChain...)
}
}
store, err := libkv.NewStore(store.Backend(kv), addrs, config)
if err != nil {

View File

@ -14,7 +14,7 @@ import (
)
func TestZooKeeperBackend(t *testing.T) {
c, err := testNewController(t, "zk", "127.0.0.1:2181")
c, err := testNewController(t, "zk", "127.0.0.1:2181/custom_prefix")
if err != nil {
t.Fatal(err)
}

View File

@ -134,12 +134,13 @@ function start_dnet() {
mkdir -p /tmp/dnet/${name}
tomlfile="/tmp/dnet/${name}/libnetwork.toml"
# Try discovery URLs with or without path
if [ "$store" = "zookeeper" ]; then
read discovery provider address < <(parse_discovery_str zk://${bridge_ip}:2182)
elif [ "$store" = "etcd" ]; then
read discovery provider address < <(parse_discovery_str etcd://${bridge_ip}:42000)
read discovery provider address < <(parse_discovery_str etcd://${bridge_ip}:42000/custom_prefix)
else
read discovery provider address < <(parse_discovery_str consul://${bridge_ip}:8500)
read discovery provider address < <(parse_discovery_str consul://${bridge_ip}:8500/custom_prefix)
fi
cat > ${tomlfile} <<EOF