Support Consul KV Enterprise namespaces
Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
parent
d969e59911
commit
b84829336d
23 changed files with 118 additions and 43 deletions
|
@ -4,7 +4,7 @@ import (
|
|||
"path"
|
||||
"reflect"
|
||||
|
||||
"github.com/abronan/valkeyrie/store"
|
||||
"github.com/kvtools/valkeyrie/store"
|
||||
"github.com/traefik/paerser/parser"
|
||||
)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/abronan/valkeyrie/store"
|
||||
"github.com/kvtools/valkeyrie/store"
|
||||
"github.com/traefik/paerser/parser"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/abronan/valkeyrie/store"
|
||||
"github.com/kvtools/valkeyrie/store"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/traefik/paerser/parser"
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package consul
|
||||
|
||||
import (
|
||||
"github.com/abronan/valkeyrie/store"
|
||||
"errors"
|
||||
|
||||
"github.com/kvtools/valkeyrie/store"
|
||||
"github.com/traefik/traefik/v2/pkg/provider"
|
||||
"github.com/traefik/traefik/v2/pkg/provider/kv"
|
||||
)
|
||||
|
@ -21,5 +23,11 @@ func (p *Provider) SetDefaults() {
|
|||
|
||||
// Init the provider.
|
||||
func (p *Provider) Init() error {
|
||||
// Wildcard namespace allows fetching KV values from any namespace for recursive requests (see https://www.consul.io/api/kv#ns).
|
||||
// As we are not supporting multiple namespaces at the same time, wildcard namespace is not allowed.
|
||||
if p.Namespace == "*" {
|
||||
return errors.New("wildcard namespace is not supported")
|
||||
}
|
||||
|
||||
return p.Provider.Init(store.CONSUL, "consul")
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package etcd
|
||||
|
||||
import (
|
||||
"github.com/abronan/valkeyrie/store"
|
||||
"github.com/kvtools/valkeyrie/store"
|
||||
"github.com/traefik/traefik/v2/pkg/provider"
|
||||
"github.com/traefik/traefik/v2/pkg/provider/kv"
|
||||
)
|
||||
|
|
|
@ -7,13 +7,13 @@ import (
|
|||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/abronan/valkeyrie"
|
||||
"github.com/abronan/valkeyrie/store"
|
||||
"github.com/abronan/valkeyrie/store/consul"
|
||||
etcdv3 "github.com/abronan/valkeyrie/store/etcd/v3"
|
||||
"github.com/abronan/valkeyrie/store/redis"
|
||||
"github.com/abronan/valkeyrie/store/zookeeper"
|
||||
"github.com/cenkalti/backoff/v4"
|
||||
"github.com/kvtools/valkeyrie"
|
||||
"github.com/kvtools/valkeyrie/store"
|
||||
"github.com/kvtools/valkeyrie/store/consul"
|
||||
etcdv3 "github.com/kvtools/valkeyrie/store/etcd/v3"
|
||||
"github.com/kvtools/valkeyrie/store/redis"
|
||||
"github.com/kvtools/valkeyrie/store/zookeeper"
|
||||
"github.com/traefik/traefik/v2/pkg/config/dynamic"
|
||||
"github.com/traefik/traefik/v2/pkg/config/kv"
|
||||
"github.com/traefik/traefik/v2/pkg/job"
|
||||
|
@ -29,6 +29,7 @@ type Provider struct {
|
|||
Endpoints []string `description:"KV store endpoints" json:"endpoints,omitempty" toml:"endpoints,omitempty" yaml:"endpoints,omitempty"`
|
||||
Username string `description:"KV Username" json:"username,omitempty" toml:"username,omitempty" yaml:"username,omitempty"`
|
||||
Password string `description:"KV Password" json:"password,omitempty" toml:"password,omitempty" yaml:"password,omitempty"`
|
||||
Namespace string `description:"KV Namespace" json:"namespace,omitempty" toml:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||
TLS *types.ClientTLS `description:"Enable TLS support" export:"true" json:"tls,omitempty" toml:"tls,omitempty" yaml:"tls,omitempty"`
|
||||
|
||||
storeType store.Backend
|
||||
|
@ -164,6 +165,7 @@ func (p *Provider) createKVClient(ctx context.Context) (store.Store, error) {
|
|||
Bucket: "traefik",
|
||||
Username: p.Username,
|
||||
Password: p.Password,
|
||||
Namespace: p.Namespace,
|
||||
}
|
||||
|
||||
if p.TLS != nil {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/abronan/valkeyrie/store"
|
||||
"github.com/kvtools/valkeyrie/store"
|
||||
)
|
||||
|
||||
func newProviderMock(kvPairs []*store.KVPair) *Provider {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/abronan/valkeyrie/store"
|
||||
"github.com/kvtools/valkeyrie/store"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
ptypes "github.com/traefik/paerser/types"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package redis
|
||||
|
||||
import (
|
||||
"github.com/abronan/valkeyrie/store"
|
||||
"github.com/kvtools/valkeyrie/store"
|
||||
"github.com/traefik/traefik/v2/pkg/provider"
|
||||
"github.com/traefik/traefik/v2/pkg/provider/kv"
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package kv
|
||||
|
||||
import (
|
||||
"github.com/abronan/valkeyrie/store"
|
||||
"github.com/kvtools/valkeyrie/store"
|
||||
"github.com/traefik/traefik/v2/pkg/log"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package zk
|
||||
|
||||
import (
|
||||
"github.com/abronan/valkeyrie/store"
|
||||
"github.com/kvtools/valkeyrie/store"
|
||||
"github.com/traefik/traefik/v2/pkg/provider"
|
||||
"github.com/traefik/traefik/v2/pkg/provider/kv"
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue