1
0
Fork 0

Migrate from libkv to valkeyrie library

This commit is contained in:
NicoMen 2018-01-24 17:52:03 +01:00 committed by Traefiker
parent a91080b060
commit 563a0bd274
33 changed files with 109 additions and 115 deletions

View file

@ -10,9 +10,9 @@ import (
"strconv"
"strings"
"github.com/abronan/valkeyrie"
"github.com/abronan/valkeyrie/store"
"github.com/containous/flaeg"
"github.com/docker/libkv"
"github.com/docker/libkv/store"
"github.com/mitchellh/mapstructure"
)
@ -27,11 +27,11 @@ type KvSource struct {
// NewKvSource creates a new KvSource
func NewKvSource(backend store.Backend, addrs []string, options *store.Config, prefix string) (*KvSource, error) {
kvStore, err := libkv.NewStore(backend, addrs, options)
kvStore, err := valkeyrie.NewStore(backend, addrs, options)
return &KvSource{Store: kvStore, Prefix: prefix}, err
}
// Parse uses libkv and mapstructure to fill the structure
// Parse uses valkeyrie and mapstructure to fill the structure
func (kv *KvSource) Parse(cmd *flaeg.Command) (*flaeg.Command, error) {
err := kv.LoadConfig(cmd.Config)
if err != nil {

View file

@ -105,14 +105,8 @@ func (ts *TomlSource) ConfigFileUsed() string {
func preprocessDir(dirIn string) (string, error) {
dirOut := dirIn
if strings.HasPrefix(dirIn, "$") {
end := strings.Index(dirIn, string(os.PathSeparator))
if end == -1 {
end = len(dirIn)
}
dirOut = os.Getenv(dirIn[1:end]) + dirIn[end:]
}
dirOut, err := filepath.Abs(dirOut)
expanded := os.ExpandEnv(dirIn)
dirOut, err := filepath.Abs(expanded)
return dirOut, err
}
@ -123,7 +117,8 @@ func findFile(filename string, dirNfile []string) string {
if fileInfo, err := os.Stat(fullPath); err == nil && !fileInfo.IsDir() {
return fullPath
}
fullPath = fullPath + "/" + filename + ".toml"
fullPath = filepath.Join(fullPath, filename+".toml")
if fileInfo, err := os.Stat(fullPath); err == nil && !fileInfo.IsDir() {
return fullPath
}