From 563a0bd274ee679c89c4a7fd0d05b9231fe32657 Mon Sep 17 00:00:00 2001 From: NicoMen Date: Wed, 24 Jan 2018 17:52:03 +0100 Subject: [PATCH] Migrate from libkv to valkeyrie library --- Gopkg.lock | 37 +++++++++---------- Gopkg.toml | 10 ++--- cluster/datastore.go | 2 +- cmd/traefik/storeconfig.go | 2 +- integration/consul_test.go | 10 ++--- integration/etcd3_test.go | 8 ++-- integration/etcd_test.go | 8 ++-- integration/try/condition.go | 2 +- provider/boltdb/boltdb.go | 6 +-- provider/consul/consul.go | 6 +-- provider/etcd/etcd.go | 8 ++-- provider/kv/filler_test.go | 2 +- provider/kv/kv.go | 6 +-- provider/kv/kv_config.go | 2 +- provider/kv/kv_config_test.go | 2 +- provider/kv/kv_mock_test.go | 2 +- provider/kv/kv_test.go | 2 +- provider/zk/zk.go | 6 +-- types/types.go | 2 +- .../libkv => abronan/valkeyrie}/LICENSE.code | 0 .../libkv => abronan/valkeyrie}/LICENSE.docs | 0 .../valkeyrie}/store/boltdb/boltdb.go | 30 +++++++-------- .../valkeyrie}/store/consul/consul.go | 8 ++-- .../valkeyrie}/store/etcd/v2/etcd.go | 8 ++-- .../valkeyrie}/store/etcd/v3/etcd.go | 8 ++-- .../valkeyrie}/store/helpers.go | 0 .../valkeyrie}/store/store.go | 4 +- .../valkeyrie}/store/zookeeper/zookeeper.go | 12 +++--- .../valkeyrie/valkeyrie.go} | 6 +-- vendor/github.com/containous/staert/kv.go | 8 ++-- vendor/github.com/containous/staert/staert.go | 13 ++----- .../github.com/docker/leadership/candidate.go | 2 +- .../github.com/docker/leadership/follower.go | 2 +- 33 files changed, 109 insertions(+), 115 deletions(-) rename vendor/github.com/{docker/libkv => abronan/valkeyrie}/LICENSE.code (100%) rename vendor/github.com/{docker/libkv => abronan/valkeyrie}/LICENSE.docs (100%) rename vendor/github.com/{docker/libkv => abronan/valkeyrie}/store/boltdb/boltdb.go (93%) rename vendor/github.com/{docker/libkv => abronan/valkeyrie}/store/consul/consul.go (98%) rename vendor/github.com/{docker/libkv => abronan/valkeyrie}/store/etcd/v2/etcd.go (99%) rename vendor/github.com/{docker/libkv => abronan/valkeyrie}/store/etcd/v3/etcd.go (98%) rename vendor/github.com/{docker/libkv => abronan/valkeyrie}/store/helpers.go (100%) rename vendor/github.com/{docker/libkv => abronan/valkeyrie}/store/store.go (98%) rename vendor/github.com/{docker/libkv => abronan/valkeyrie}/store/zookeeper/zookeeper.go (98%) rename vendor/github.com/{docker/libkv/libkv.go => abronan/valkeyrie/valkeyrie.go} (89%) diff --git a/Gopkg.lock b/Gopkg.lock index 0d39c3ce8..6a3201050 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -126,6 +126,20 @@ revision = "65b0cdae8d7fe5c05c7430e055938ef6d24a66c9" source = "github.com/containous/go-http-auth" +[[projects]] + branch = "master" + name = "github.com/abronan/valkeyrie" + packages = [ + ".", + "store", + "store/boltdb", + "store/consul", + "store/etcd/v2", + "store/etcd/v3", + "store/zookeeper" + ] + revision = "063d875e3c5fd734fa2aa12fac83829f62acfc70" + [[projects]] name = "github.com/aokoli/goutils" packages = ["."] @@ -235,8 +249,8 @@ [[projects]] name = "github.com/containous/staert" packages = ["."] - revision = "af517d5b70db9c4b0505e0144fcc62b054057d2a" - version = "v2.0.0" + revision = "dbb7c840f31daec0d863ada6829d075a8dbb7469" + version = "v3.0.0" [[projects]] name = "github.com/containous/traefik-extra-service-fabric" @@ -427,7 +441,7 @@ branch = "master" name = "github.com/docker/leadership" packages = ["."] - revision = "af20da7d3e62be9259835e93261acf931b5adecf" + revision = "a2e096d9fe0af5b4c37dd37aea719bc9c2e5eec6" source = "github.com/containous/leadership" [[projects]] @@ -457,21 +471,6 @@ ] revision = "57bd716502dcbe1799f026148016022b0f3b989c" -[[projects]] - branch = "master" - name = "github.com/docker/libkv" - packages = [ - ".", - "store", - "store/boltdb", - "store/consul", - "store/etcd/v2", - "store/etcd/v3", - "store/zookeeper" - ] - revision = "5e4bb288a9a74320bb03f5c18d6bdbab0d8049de" - source = "github.com/abronan/libkv" - [[projects]] name = "github.com/donovanhide/eventsource" packages = ["."] @@ -1513,6 +1512,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "abd30ec16123cf6de5a869dcaba3e3247907785b4802f0eebaa0cf4d16ef444b" + inputs-digest = "0d3d2cd01e06cfcc86cbd261395d59187d4d27d88398bd7aeb1298676becd3e7" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 3d04ece66..5d57884cf 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -62,7 +62,7 @@ [[constraint]] name = "github.com/containous/staert" - version = "2.0.0" + version = "3.0.0" [[constraint]] name = "github.com/containous/traefik-extra-service-fabric" @@ -77,10 +77,6 @@ name = "github.com/docker/leadership" source = "github.com/containous/leadership" -[[constraint]] - name = "github.com/docker/libkv" - source = "github.com/abronan/libkv" - [[constraint]] name = "github.com/eapache/channels" version = "1.1.0" @@ -115,6 +111,10 @@ branch = "master" name = "github.com/jjcollinge/servicefabric" +[[constraint]] + branch = "master" + name = "github.com/abronan/valkeyrie" + [[constraint]] name = "github.com/mattn/go-shellwords" version = "1.0.3" diff --git a/cluster/datastore.go b/cluster/datastore.go index 11aee8a5b..add941aa1 100644 --- a/cluster/datastore.go +++ b/cluster/datastore.go @@ -7,12 +7,12 @@ import ( "sync" "time" + "github.com/abronan/valkeyrie/store" "github.com/cenk/backoff" "github.com/containous/staert" "github.com/containous/traefik/job" "github.com/containous/traefik/log" "github.com/containous/traefik/safe" - "github.com/docker/libkv/store" "github.com/satori/go.uuid" ) diff --git a/cmd/traefik/storeconfig.go b/cmd/traefik/storeconfig.go index 1e4e40a86..d1ef52a5d 100644 --- a/cmd/traefik/storeconfig.go +++ b/cmd/traefik/storeconfig.go @@ -5,11 +5,11 @@ import ( "fmt" stdlog "log" + "github.com/abronan/valkeyrie/store" "github.com/containous/flaeg" "github.com/containous/staert" "github.com/containous/traefik/acme" "github.com/containous/traefik/cluster" - "github.com/docker/libkv/store" ) func newStoreConfigCmd(traefikConfiguration *TraefikConfiguration, traefikPointersConfiguration *TraefikConfiguration) *flaeg.Command { diff --git a/integration/consul_test.go b/integration/consul_test.go index b404ae57f..e0fe3374b 100644 --- a/integration/consul_test.go +++ b/integration/consul_test.go @@ -10,13 +10,13 @@ import ( "sync" "time" + "github.com/abronan/valkeyrie" + "github.com/abronan/valkeyrie/store" + "github.com/abronan/valkeyrie/store/consul" "github.com/containous/staert" "github.com/containous/traefik/cluster" "github.com/containous/traefik/integration/try" "github.com/containous/traefik/types" - "github.com/docker/libkv" - "github.com/docker/libkv/store" - "github.com/docker/libkv/store/consul" "github.com/go-check/check" checker "github.com/vdemeester/shakers" ) @@ -32,7 +32,7 @@ func (s *ConsulSuite) setupConsul(c *check.C) { s.composeProject.Start(c) consul.Register() - kv, err := libkv.NewStore( + kv, err := valkeyrie.NewStore( store.CONSUL, []string{s.composeProject.Container(c, "consul").NetworkSettings.IPAddress + ":8500"}, &store.Config{ @@ -63,7 +63,7 @@ func (s *ConsulSuite) setupConsulTLS(c *check.C) { TLSConfig, err := clientTLS.CreateTLSConfig() c.Assert(err, checker.IsNil) - kv, err := libkv.NewStore( + kv, err := valkeyrie.NewStore( store.CONSUL, []string{s.composeProject.Container(c, "consul").NetworkSettings.IPAddress + ":8585"}, &store.Config{ diff --git a/integration/etcd3_test.go b/integration/etcd3_test.go index 04bf068ef..0d01d861e 100644 --- a/integration/etcd3_test.go +++ b/integration/etcd3_test.go @@ -8,10 +8,10 @@ import ( "strings" "time" + "github.com/abronan/valkeyrie" + "github.com/abronan/valkeyrie/store" + "github.com/abronan/valkeyrie/store/etcd/v3" "github.com/containous/traefik/integration/try" - "github.com/docker/libkv" - "github.com/docker/libkv/store" - "github.com/docker/libkv/store/etcd/v3" "github.com/go-check/check" checker "github.com/vdemeester/shakers" @@ -41,7 +41,7 @@ func (s *Etcd3Suite) SetUpTest(c *check.C) { etcdv3.Register() url := ipEtcd + ":2379" - kv, err := libkv.NewStore( + kv, err := valkeyrie.NewStore( store.ETCDV3, []string{url}, &store.Config{ diff --git a/integration/etcd_test.go b/integration/etcd_test.go index 4368b2a64..6e6133f86 100644 --- a/integration/etcd_test.go +++ b/integration/etcd_test.go @@ -8,10 +8,10 @@ import ( "strings" "time" + "github.com/abronan/valkeyrie" + "github.com/abronan/valkeyrie/store" + "github.com/abronan/valkeyrie/store/etcd/v2" "github.com/containous/traefik/integration/try" - "github.com/docker/libkv" - "github.com/docker/libkv/store" - "github.com/docker/libkv/store/etcd/v2" "github.com/go-check/check" checker "github.com/vdemeester/shakers" @@ -29,7 +29,7 @@ func (s *EtcdSuite) SetUpTest(c *check.C) { etcd.Register() url := s.composeProject.Container(c, "etcd").NetworkSettings.IPAddress + ":2379" - kv, err := libkv.NewStore( + kv, err := valkeyrie.NewStore( store.ETCD, []string{url}, &store.Config{ diff --git a/integration/try/condition.go b/integration/try/condition.go index 93010631f..e7ee9c9d2 100644 --- a/integration/try/condition.go +++ b/integration/try/condition.go @@ -7,7 +7,7 @@ import ( "net/http" "strings" - "github.com/docker/libkv/store" + "github.com/abronan/valkeyrie/store" ) // ResponseCondition is a retry condition function. diff --git a/provider/boltdb/boltdb.go b/provider/boltdb/boltdb.go index 0a043ec94..f476d7729 100644 --- a/provider/boltdb/boltdb.go +++ b/provider/boltdb/boltdb.go @@ -3,12 +3,12 @@ package boltdb import ( "fmt" + "github.com/abronan/valkeyrie/store" + "github.com/abronan/valkeyrie/store/boltdb" "github.com/containous/traefik/provider" "github.com/containous/traefik/provider/kv" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" - "github.com/docker/libkv/store" - "github.com/docker/libkv/store/boltdb" ) var _ provider.Provider = (*Provider)(nil) @@ -23,7 +23,7 @@ type Provider struct { func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints types.Constraints) error { store, err := p.CreateStore() if err != nil { - return fmt.Errorf("Failed to Connect to KV store: %v", err) + return fmt.Errorf("failed to Connect to KV store: %v", err) } p.SetKVClient(store) return p.Provider.Provide(configurationChan, pool, constraints) diff --git a/provider/consul/consul.go b/provider/consul/consul.go index ff4737346..87d203314 100644 --- a/provider/consul/consul.go +++ b/provider/consul/consul.go @@ -3,12 +3,12 @@ package consul import ( "fmt" + "github.com/abronan/valkeyrie/store" + "github.com/abronan/valkeyrie/store/consul" "github.com/containous/traefik/provider" "github.com/containous/traefik/provider/kv" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" - "github.com/docker/libkv/store" - "github.com/docker/libkv/store/consul" ) var _ provider.Provider = (*Provider)(nil) @@ -23,7 +23,7 @@ type Provider struct { func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints types.Constraints) error { store, err := p.CreateStore() if err != nil { - return fmt.Errorf("Failed to Connect to KV store: %v", err) + return fmt.Errorf("failed to Connect to KV store: %v", err) } p.SetKVClient(store) return p.Provider.Provide(configurationChan, pool, constraints) diff --git a/provider/etcd/etcd.go b/provider/etcd/etcd.go index 97d7a968c..4d1bb4f74 100644 --- a/provider/etcd/etcd.go +++ b/provider/etcd/etcd.go @@ -3,14 +3,14 @@ package etcd import ( "fmt" + "github.com/abronan/valkeyrie/store" + "github.com/abronan/valkeyrie/store/etcd/v2" + "github.com/abronan/valkeyrie/store/etcd/v3" "github.com/containous/traefik/log" "github.com/containous/traefik/provider" "github.com/containous/traefik/provider/kv" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" - "github.com/docker/libkv/store" - "github.com/docker/libkv/store/etcd/v2" - "github.com/docker/libkv/store/etcd/v3" ) var _ provider.Provider = (*Provider)(nil) @@ -26,7 +26,7 @@ type Provider struct { func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints types.Constraints) error { store, err := p.CreateStore() if err != nil { - return fmt.Errorf("Failed to Connect to KV store: %v", err) + return fmt.Errorf("failed to Connect to KV store: %v", err) } p.SetKVClient(store) return p.Provider.Provide(configurationChan, pool, constraints) diff --git a/provider/kv/filler_test.go b/provider/kv/filler_test.go index e09de2d03..806bdbead 100644 --- a/provider/kv/filler_test.go +++ b/provider/kv/filler_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/docker/libkv/store" + "github.com/abronan/valkeyrie/store" "github.com/stretchr/testify/assert" ) diff --git a/provider/kv/kv.go b/provider/kv/kv.go index b6393cc24..c7223946c 100644 --- a/provider/kv/kv.go +++ b/provider/kv/kv.go @@ -6,14 +6,14 @@ import ( "strings" "time" + "github.com/abronan/valkeyrie" + "github.com/abronan/valkeyrie/store" "github.com/cenk/backoff" "github.com/containous/traefik/job" "github.com/containous/traefik/log" "github.com/containous/traefik/provider" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" - "github.com/docker/libkv" - "github.com/docker/libkv/store" ) // Provider holds common configurations of key-value providers. @@ -44,7 +44,7 @@ func (p *Provider) CreateStore() (store.Store, error) { return nil, err } } - return libkv.NewStore( + return valkeyrie.NewStore( p.storeType, strings.Split(p.Endpoint, ","), storeConfig, diff --git a/provider/kv/kv_config.go b/provider/kv/kv_config.go index 0dc4f7df1..e3800d022 100644 --- a/provider/kv/kv_config.go +++ b/provider/kv/kv_config.go @@ -10,12 +10,12 @@ import ( "text/template" "github.com/BurntSushi/ty/fun" + "github.com/abronan/valkeyrie/store" "github.com/containous/flaeg" "github.com/containous/traefik/log" "github.com/containous/traefik/provider/label" "github.com/containous/traefik/tls" "github.com/containous/traefik/types" - "github.com/docker/libkv/store" ) func (p *Provider) buildConfiguration() *types.Configuration { diff --git a/provider/kv/kv_config_test.go b/provider/kv/kv_config_test.go index 62b4e3462..0eae28959 100644 --- a/provider/kv/kv_config_test.go +++ b/provider/kv/kv_config_test.go @@ -6,11 +6,11 @@ import ( "testing" "time" + "github.com/abronan/valkeyrie/store" "github.com/containous/flaeg" "github.com/containous/traefik/provider/label" "github.com/containous/traefik/tls" "github.com/containous/traefik/types" - "github.com/docker/libkv/store" "github.com/stretchr/testify/assert" ) diff --git a/provider/kv/kv_mock_test.go b/provider/kv/kv_mock_test.go index eab65d7df..ef7280207 100644 --- a/provider/kv/kv_mock_test.go +++ b/provider/kv/kv_mock_test.go @@ -4,7 +4,7 @@ import ( "errors" "strings" - "github.com/docker/libkv/store" + "github.com/abronan/valkeyrie/store" ) func newProviderMock(kvPairs []*store.KVPair) *Provider { diff --git a/provider/kv/kv_test.go b/provider/kv/kv_test.go index 3a7ac472b..e82da84eb 100644 --- a/provider/kv/kv_test.go +++ b/provider/kv/kv_test.go @@ -4,8 +4,8 @@ import ( "testing" "time" + "github.com/abronan/valkeyrie/store" "github.com/containous/traefik/types" - "github.com/docker/libkv/store" ) func TestKvWatchTree(t *testing.T) { diff --git a/provider/zk/zk.go b/provider/zk/zk.go index 28f8a2e26..b889c9eb1 100644 --- a/provider/zk/zk.go +++ b/provider/zk/zk.go @@ -3,12 +3,12 @@ package zk import ( "fmt" + "github.com/abronan/valkeyrie/store" + "github.com/abronan/valkeyrie/store/zookeeper" "github.com/containous/traefik/provider" "github.com/containous/traefik/provider/kv" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" - "github.com/docker/libkv/store" - "github.com/docker/libkv/store/zookeeper" ) var _ provider.Provider = (*Provider)(nil) @@ -23,7 +23,7 @@ type Provider struct { func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints types.Constraints) error { store, err := p.CreateStore() if err != nil { - return fmt.Errorf("Failed to Connect to KV store: %v", err) + return fmt.Errorf("failed to Connect to KV store: %v", err) } p.SetKVClient(store) return p.Provider.Provide(configurationChan, pool, constraints) diff --git a/types/types.go b/types/types.go index fba8835ed..0ec8a4a10 100644 --- a/types/types.go +++ b/types/types.go @@ -11,10 +11,10 @@ import ( "strconv" "strings" + "github.com/abronan/valkeyrie/store" "github.com/containous/flaeg" "github.com/containous/traefik/log" traefikTls "github.com/containous/traefik/tls" - "github.com/docker/libkv/store" "github.com/ryanuber/go-glob" ) diff --git a/vendor/github.com/docker/libkv/LICENSE.code b/vendor/github.com/abronan/valkeyrie/LICENSE.code similarity index 100% rename from vendor/github.com/docker/libkv/LICENSE.code rename to vendor/github.com/abronan/valkeyrie/LICENSE.code diff --git a/vendor/github.com/docker/libkv/LICENSE.docs b/vendor/github.com/abronan/valkeyrie/LICENSE.docs similarity index 100% rename from vendor/github.com/docker/libkv/LICENSE.docs rename to vendor/github.com/abronan/valkeyrie/LICENSE.docs diff --git a/vendor/github.com/docker/libkv/store/boltdb/boltdb.go b/vendor/github.com/abronan/valkeyrie/store/boltdb/boltdb.go similarity index 93% rename from vendor/github.com/docker/libkv/store/boltdb/boltdb.go rename to vendor/github.com/abronan/valkeyrie/store/boltdb/boltdb.go index afe9e4b61..5c553c3be 100644 --- a/vendor/github.com/docker/libkv/store/boltdb/boltdb.go +++ b/vendor/github.com/abronan/valkeyrie/store/boltdb/boltdb.go @@ -10,9 +10,9 @@ import ( "sync/atomic" "time" + "github.com/abronan/valkeyrie" + "github.com/abronan/valkeyrie/store" "github.com/coreos/bbolt" - "github.com/docker/libkv" - "github.com/docker/libkv/store" ) var ( @@ -34,7 +34,7 @@ type BoltDB struct { dbIndex uint64 path string timeout time.Duration - // By default libkv opens and closes the bolt DB connection for every + // By default valkeyrie opens and closes the bolt DB connection for every // get/put operation. This allows multiple apps to use a Bolt DB at the // same time. // PersistConnection flag provides an option to override ths behavior. @@ -44,13 +44,13 @@ type BoltDB struct { } const ( - libkvmetadatalen = 8 + metadatalen = 8 transientTimeout = time.Duration(10) * time.Second ) -// Register registers boltdb to libkv +// Register registers boltdb to valkeyrie func Register() { - libkv.AddStore(store.BOLTDB, New) + valkeyrie.AddStore(store.BOLTDB, New) } // New opens a new BoltDB connection to the specified path and bucket @@ -126,7 +126,7 @@ func (b *BoltDB) releaseDBhandle() { } // Get the value at "key". BoltDB doesn't provide an inbuilt last modified index with every kv pair. Its implemented by -// by a atomic counter maintained by the libkv and appened to the value passed by the client. +// by a atomic counter maintained by the valkeyrie and appened to the value passed by the client. func (b *BoltDB) Get(key string, opts *store.ReadOptions) (*store.KVPair, error) { var ( val []byte @@ -161,8 +161,8 @@ func (b *BoltDB) Get(key string, opts *store.ReadOptions) (*store.KVPair, error) return nil, err } - dbIndex := binary.LittleEndian.Uint64(val[:libkvmetadatalen]) - val = val[libkvmetadatalen:] + dbIndex := binary.LittleEndian.Uint64(val[:metadatalen]) + val = val[metadatalen:] return &store.KVPair{Key: key, Value: val, LastIndex: (dbIndex)}, nil } @@ -177,7 +177,7 @@ func (b *BoltDB) Put(key string, value []byte, opts *store.WriteOptions) error { b.Lock() defer b.Unlock() - dbval := make([]byte, libkvmetadatalen) + dbval := make([]byte, metadatalen) if db, err = b.getDBhandle(); err != nil { return err @@ -287,8 +287,8 @@ func (b *BoltDB) List(keyPrefix string, opts *store.ReadOptions) ([]*store.KVPai for key, v := cursor.Seek(prefix); bytes.HasPrefix(key, prefix); key, v = cursor.Next() { hasResult = true - dbIndex := binary.LittleEndian.Uint64(v[:libkvmetadatalen]) - v = v[libkvmetadatalen:] + dbIndex := binary.LittleEndian.Uint64(v[:metadatalen]) + v = v[metadatalen:] val := make([]byte, len(v)) copy(val, v) @@ -338,7 +338,7 @@ func (b *BoltDB) AtomicDelete(key string, previous *store.KVPair) (bool, error) if val == nil { return store.ErrKeyNotFound } - dbIndex := binary.LittleEndian.Uint64(val[:libkvmetadatalen]) + dbIndex := binary.LittleEndian.Uint64(val[:metadatalen]) if dbIndex != previous.LastIndex { return store.ErrKeyModified } @@ -363,7 +363,7 @@ func (b *BoltDB) AtomicPut(key string, value []byte, previous *store.KVPair, opt b.Lock() defer b.Unlock() - dbval := make([]byte, libkvmetadatalen) + dbval := make([]byte, metadatalen) if db, err = b.getDBhandle(); err != nil { return false, nil, err @@ -392,7 +392,7 @@ func (b *BoltDB) AtomicPut(key string, value []byte, previous *store.KVPair, opt if len(val) == 0 { return store.ErrKeyNotFound } - dbIndex = binary.LittleEndian.Uint64(val[:libkvmetadatalen]) + dbIndex = binary.LittleEndian.Uint64(val[:metadatalen]) if dbIndex != previous.LastIndex { return store.ErrKeyModified } diff --git a/vendor/github.com/docker/libkv/store/consul/consul.go b/vendor/github.com/abronan/valkeyrie/store/consul/consul.go similarity index 98% rename from vendor/github.com/docker/libkv/store/consul/consul.go rename to vendor/github.com/abronan/valkeyrie/store/consul/consul.go index d62c63d78..aeb176409 100644 --- a/vendor/github.com/docker/libkv/store/consul/consul.go +++ b/vendor/github.com/abronan/valkeyrie/store/consul/consul.go @@ -8,8 +8,8 @@ import ( "sync" "time" - "github.com/docker/libkv" - "github.com/docker/libkv/store" + "github.com/abronan/valkeyrie" + "github.com/abronan/valkeyrie/store" api "github.com/hashicorp/consul/api" ) @@ -55,9 +55,9 @@ type consulLock struct { renewCh chan struct{} } -// Register registers consul to libkv +// Register registers consul to valkeyrie func Register() { - libkv.AddStore(store.CONSUL, New) + valkeyrie.AddStore(store.CONSUL, New) } // New creates a new Consul client given a list diff --git a/vendor/github.com/docker/libkv/store/etcd/v2/etcd.go b/vendor/github.com/abronan/valkeyrie/store/etcd/v2/etcd.go similarity index 99% rename from vendor/github.com/docker/libkv/store/etcd/v2/etcd.go rename to vendor/github.com/abronan/valkeyrie/store/etcd/v2/etcd.go index d332c7cd6..22edee861 100644 --- a/vendor/github.com/docker/libkv/store/etcd/v2/etcd.go +++ b/vendor/github.com/abronan/valkeyrie/store/etcd/v2/etcd.go @@ -12,9 +12,9 @@ import ( "golang.org/x/net/context" + "github.com/abronan/valkeyrie" + "github.com/abronan/valkeyrie/store" etcd "github.com/coreos/etcd/client" - "github.com/docker/libkv" - "github.com/docker/libkv/store" ) const ( @@ -53,9 +53,9 @@ const ( defaultUpdateTime = 5 * time.Second ) -// Register registers etcd to libkv +// Register registers etcd to valkeyrie func Register() { - libkv.AddStore(store.ETCD, New) + valkeyrie.AddStore(store.ETCD, New) } // New creates a new Etcd client given a list diff --git a/vendor/github.com/docker/libkv/store/etcd/v3/etcd.go b/vendor/github.com/abronan/valkeyrie/store/etcd/v3/etcd.go similarity index 98% rename from vendor/github.com/docker/libkv/store/etcd/v3/etcd.go rename to vendor/github.com/abronan/valkeyrie/store/etcd/v3/etcd.go index fdd068e26..7f54cc9fd 100644 --- a/vendor/github.com/docker/libkv/store/etcd/v3/etcd.go +++ b/vendor/github.com/abronan/valkeyrie/store/etcd/v3/etcd.go @@ -7,10 +7,10 @@ import ( "sync" "time" + "github.com/abronan/valkeyrie" + "github.com/abronan/valkeyrie/store" etcd "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" - "github.com/docker/libkv" - "github.com/docker/libkv/store" ) const ( @@ -38,9 +38,9 @@ type etcdLock struct { ttl time.Duration } -// Register registers etcd to libkv +// Register registers etcd to valkeyrie func Register() { - libkv.AddStore(store.ETCDV3, New) + valkeyrie.AddStore(store.ETCDV3, New) } // New creates a new Etcd client given a list diff --git a/vendor/github.com/docker/libkv/store/helpers.go b/vendor/github.com/abronan/valkeyrie/store/helpers.go similarity index 100% rename from vendor/github.com/docker/libkv/store/helpers.go rename to vendor/github.com/abronan/valkeyrie/store/helpers.go diff --git a/vendor/github.com/docker/libkv/store/store.go b/vendor/github.com/abronan/valkeyrie/store/store.go similarity index 98% rename from vendor/github.com/docker/libkv/store/store.go rename to vendor/github.com/abronan/valkeyrie/store/store.go index cbb59ce11..acc25f909 100644 --- a/vendor/github.com/docker/libkv/store/store.go +++ b/vendor/github.com/abronan/valkeyrie/store/store.go @@ -25,7 +25,7 @@ const ( ) var ( - // ErrBackendNotSupported is thrown when the backend k/v store is not supported by libkv + // ErrBackendNotSupported is thrown when the backend k/v store is not supported by valkeyrie ErrBackendNotSupported = errors.New("Backend storage not supported yet, please choose one of") // ErrCallNotSupported is thrown when a method is not implemented/supported by the current backend ErrCallNotSupported = errors.New("The current call is not supported with this backend") @@ -66,7 +66,7 @@ type ClientTLSConfig struct { // Store represents the backend K/V storage // Each store should support every call listed // here. Or it couldn't be implemented as a K/V -// backend for libkv +// backend for valkeyrie type Store interface { // Put a value at the specified key Put(key string, value []byte, options *WriteOptions) error diff --git a/vendor/github.com/docker/libkv/store/zookeeper/zookeeper.go b/vendor/github.com/abronan/valkeyrie/store/zookeeper/zookeeper.go similarity index 98% rename from vendor/github.com/docker/libkv/store/zookeeper/zookeeper.go rename to vendor/github.com/abronan/valkeyrie/store/zookeeper/zookeeper.go index ccbd53792..40f2834ba 100644 --- a/vendor/github.com/docker/libkv/store/zookeeper/zookeeper.go +++ b/vendor/github.com/abronan/valkeyrie/store/zookeeper/zookeeper.go @@ -4,8 +4,8 @@ import ( "strings" "time" - "github.com/docker/libkv" - "github.com/docker/libkv/store" + "github.com/abronan/valkeyrie" + "github.com/abronan/valkeyrie/store" zk "github.com/samuel/go-zookeeper/zk" ) @@ -32,9 +32,9 @@ type zookeeperLock struct { value []byte } -// Register registers zookeeper to libkv +// Register registers zookeeper to valkeyrie func Register() { - libkv.AddStore(store.ZK, New) + valkeyrie.AddStore(store.ZK, New) } // New creates a new Zookeeper client given a @@ -485,7 +485,7 @@ func (s *Zookeeper) get(key string) ([]byte, *zk.Stat, error) { var meta *zk.Stat var err error - // To guard against older versions of libkv + // To guard against older versions of valkeyrie // creating and writing to znodes non-atomically, // We try to resync few times if we read SOH or // an empty string @@ -518,7 +518,7 @@ func (s *Zookeeper) getW(key string) ([]byte, *zk.Stat, <-chan zk.Event, error) var ech <-chan zk.Event var err error - // To guard against older versions of libkv + // To guard against older versions of valkeyrie // creating and writing to znodes non-atomically, // We try to resync few times if we read SOH or // an empty string diff --git a/vendor/github.com/docker/libkv/libkv.go b/vendor/github.com/abronan/valkeyrie/valkeyrie.go similarity index 89% rename from vendor/github.com/docker/libkv/libkv.go rename to vendor/github.com/abronan/valkeyrie/valkeyrie.go index bdb8c7529..5bd7964b5 100644 --- a/vendor/github.com/docker/libkv/libkv.go +++ b/vendor/github.com/abronan/valkeyrie/valkeyrie.go @@ -1,11 +1,11 @@ -package libkv +package valkeyrie import ( "fmt" "sort" "strings" - "github.com/docker/libkv/store" + "github.com/abronan/valkeyrie/store" ) // Initialize creates a new Store object, initializing the client @@ -34,7 +34,7 @@ func NewStore(backend store.Backend, addrs []string, options *store.Config) (sto return nil, fmt.Errorf("%s %s", store.ErrBackendNotSupported.Error(), supportedBackend) } -// AddStore adds a new store backend to libkv +// AddStore adds a new store backend to valkeyrie func AddStore(store store.Backend, init Initialize) { initializers[store] = init } diff --git a/vendor/github.com/containous/staert/kv.go b/vendor/github.com/containous/staert/kv.go index 949e03642..898000cc3 100644 --- a/vendor/github.com/containous/staert/kv.go +++ b/vendor/github.com/containous/staert/kv.go @@ -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 { diff --git a/vendor/github.com/containous/staert/staert.go b/vendor/github.com/containous/staert/staert.go index ccd6f200a..cf56d39ee 100644 --- a/vendor/github.com/containous/staert/staert.go +++ b/vendor/github.com/containous/staert/staert.go @@ -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 } diff --git a/vendor/github.com/docker/leadership/candidate.go b/vendor/github.com/docker/leadership/candidate.go index 8b96f281f..3a4cd852a 100644 --- a/vendor/github.com/docker/leadership/candidate.go +++ b/vendor/github.com/docker/leadership/candidate.go @@ -4,7 +4,7 @@ import ( "sync" "time" - "github.com/docker/libkv/store" + "github.com/abronan/valkeyrie/store" ) const ( diff --git a/vendor/github.com/docker/leadership/follower.go b/vendor/github.com/docker/leadership/follower.go index 20f77d40a..a41c72063 100644 --- a/vendor/github.com/docker/leadership/follower.go +++ b/vendor/github.com/docker/leadership/follower.go @@ -3,7 +3,7 @@ package leadership import ( "errors" - "github.com/docker/libkv/store" + "github.com/abronan/valkeyrie/store" ) // Follower can follow an election in real-time and push notifications whenever