Vendor main dependencies.
This commit is contained in:
parent
49a09ab7dd
commit
dd5e3fba01
2738 changed files with 1045689 additions and 0 deletions
47
vendor/github.com/docker/libkv/store/helpers.go
generated
vendored
Normal file
47
vendor/github.com/docker/libkv/store/helpers.go
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
package store
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CreateEndpoints creates a list of endpoints given the right scheme
|
||||
func CreateEndpoints(addrs []string, scheme string) (entries []string) {
|
||||
for _, addr := range addrs {
|
||||
entries = append(entries, scheme+"://"+addr)
|
||||
}
|
||||
return entries
|
||||
}
|
||||
|
||||
// Normalize the key for each store to the form:
|
||||
//
|
||||
// /path/to/key
|
||||
//
|
||||
func Normalize(key string) string {
|
||||
return "/" + join(SplitKey(key))
|
||||
}
|
||||
|
||||
// GetDirectory gets the full directory part of
|
||||
// the key to the form:
|
||||
//
|
||||
// /path/to/
|
||||
//
|
||||
func GetDirectory(key string) string {
|
||||
parts := SplitKey(key)
|
||||
parts = parts[:len(parts)-1]
|
||||
return "/" + join(parts)
|
||||
}
|
||||
|
||||
// SplitKey splits the key to extract path informations
|
||||
func SplitKey(key string) (path []string) {
|
||||
if strings.Contains(key, "/") {
|
||||
path = strings.Split(key, "/")
|
||||
} else {
|
||||
path = []string{key}
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// join the path parts with '/'
|
||||
func join(parts []string) string {
|
||||
return strings.Join(parts, "/")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue