1
0
Fork 0

Update valkeyrie to v1.0.0

This commit is contained in:
Ludovic Fernandez 2022-09-12 17:40:09 +02:00 committed by GitHub
parent d578ed7327
commit d531963f95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 254 additions and 289 deletions

View file

@ -1,16 +1,25 @@
package redis
import (
"github.com/kvtools/valkeyrie/store"
"context"
"fmt"
"github.com/kvtools/redis"
"github.com/traefik/traefik/v2/pkg/provider"
"github.com/traefik/traefik/v2/pkg/provider/kv"
"github.com/traefik/traefik/v2/pkg/types"
)
var _ provider.Provider = (*Provider)(nil)
// Provider holds configurations of the provider.
type Provider struct {
kv.Provider `export:"true"`
kv.Provider `yaml:",inline" export:"true"`
TLS *types.ClientTLS `description:"Enable TLS support." json:"tls,omitempty" toml:"tls,omitempty" yaml:"tls,omitempty" export:"true"`
Username string `description:"Username for authentication." json:"username,omitempty" toml:"username,omitempty" yaml:"username,omitempty" loggable:"false"`
Password string `description:"Password for authentication." json:"password,omitempty" toml:"password,omitempty" yaml:"password,omitempty" loggable:"false"`
DB int `description:"Database to be selected after connecting to the server." json:"db,omitempty" toml:"db,omitempty" yaml:"db,omitempty"`
}
// SetDefaults sets the default values.
@ -21,5 +30,19 @@ func (p *Provider) SetDefaults() {
// Init the provider.
func (p *Provider) Init() error {
return p.Provider.Init(store.REDIS, "redis", "")
config := redis.Config{
Username: p.Username,
Password: p.Password,
DB: p.DB,
}
if p.TLS != nil {
var err error
config.TLS, err = p.TLS.CreateTLSConfig(context.Background())
if err != nil {
return fmt.Errorf("unable to create client TLS configuration: %w", err)
}
}
return p.Provider.Init(redis.StoreName, "redis", config)
}