Browse Source

libnetwork/datastore: remove unused ParseKey() utility

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 2 years ago
parent
commit
f70e1b315f
2 changed files with 0 additions and 24 deletions
  1. 0 12
      libnetwork/datastore/datastore.go
  2. 0 12
      libnetwork/datastore/datastore_test.go

+ 0 - 12
libnetwork/datastore/datastore.go

@@ -2,7 +2,6 @@ package datastore
 
 import (
 	"fmt"
-	"reflect"
 	"strings"
 	"sync"
 	"time"
@@ -132,17 +131,6 @@ func Key(key ...string) string {
 	return str + "/"
 }
 
-// ParseKey provides convenient method to unpack the key to complement the Key function
-func ParseKey(key string) ([]string, error) {
-	chain := strings.Split(strings.Trim(key, "/"), "/")
-
-	// The key must at least be equal to the rootChain in order to be considered as valid
-	if len(chain) <= len(rootChain) || !reflect.DeepEqual(chain[0:len(rootChain)], rootChain) {
-		return nil, types.BadRequestErrorf("invalid Key : %s", key)
-	}
-	return chain[len(rootChain):], nil
-}
-
 // newClient used to connect to KV Store
 func newClient(kv string, addr string, config *store.Config) (*Store, error) {
 	if config == nil {

+ 0 - 12
libnetwork/datastore/datastore_test.go

@@ -2,7 +2,6 @@ package datastore
 
 import (
 	"encoding/json"
-	"reflect"
 	"testing"
 
 	"github.com/docker/docker/libnetwork/options"
@@ -24,17 +23,6 @@ func TestKey(t *testing.T) {
 	}
 }
 
-func TestParseKey(t *testing.T) {
-	keySlice, err := ParseKey("/docker/network/v1.0/hello/world/")
-	if err != nil {
-		t.Fatal(err)
-	}
-	eKey := []string{"hello", "world"}
-	if len(keySlice) < 2 || !reflect.DeepEqual(eKey, keySlice) {
-		t.Fatalf("unexpected unkey : %s", keySlice)
-	}
-}
-
 func TestInvalidDataStore(t *testing.T) {
 	_, err := New(ScopeCfg{
 		Client: ScopeClientCfg{