Переглянути джерело

Fix the issue for the --cluster-store URL with path

Change-Id: I6542ceb28f70e2c6bf2162462255359362594c6d
Signed-off-by: Li Yi <denverdino@gmail.com>
Li Yi 9 роки тому
батько
коміт
b339bb2707
1 змінених файлів з 11 додано та 2 видалено
  1. 11 2
      libnetwork/datastore/datastore.go

+ 11 - 2
libnetwork/datastore/datastore.go

@@ -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,11 @@ 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) {
+	var (
+		parts = strings.SplitN(addr, "/", 2)
+		addrs = strings.Split(parts[0], ",")
+	)
+
 	if cached && scope != LocalScope {
 		return nil, fmt.Errorf("caching supported only for scope %s", LocalScope)
 	}
@@ -203,7 +209,10 @@ func newClient(scope string, kv string, addr string, config *store.Config, cache
 		config = &store.Config{}
 	}
 
-	addrs := strings.Split(addr, ",")
+	// 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 {