feat: support prefix.

This commit is contained in:
Fernandez Ludovic 2019-04-20 17:27:09 +02:00
parent 3283611d7f
commit ddf94bb963
3 changed files with 7 additions and 21 deletions

View File

@ -20,6 +20,7 @@ func init() {
kvCmd.PersistentFlags().StringSlice("endpoints", []string{"localhost:8500"}, "Comma separated list of endpoints.") kvCmd.PersistentFlags().StringSlice("endpoints", []string{"localhost:8500"}, "Comma separated list of endpoints.")
kvCmd.PersistentFlags().Int("connection-timeout", 0, "Connection timeout in seconds.") kvCmd.PersistentFlags().Int("connection-timeout", 0, "Connection timeout in seconds.")
kvCmd.PersistentFlags().String("prefix", "traefik", "Prefix used for KV store.")
kvCmd.PersistentFlags().String("password", "", "Password for connection.") kvCmd.PersistentFlags().String("password", "", "Password for connection.")
kvCmd.PersistentFlags().String("username", "", "Username for connection.") kvCmd.PersistentFlags().String("username", "", "Username for connection.")
@ -40,28 +41,13 @@ func getKvConfig(cmd *cobra.Command) (*kv.Config, error) {
return nil, err return nil, err
} }
password, err := cmd.Flags().GetString("password")
if err != nil {
return nil, err
}
username, err := cmd.Flags().GetString("username")
if err != nil {
return nil, err
}
return &kv.Config{ return &kv.Config{
Endpoints: endpoints, Endpoints: endpoints,
Prefix: cmd.Flag("prefix").Value.String(),
Options: &store.Config{ Options: &store.Config{
ClientTLS: nil,
TLS: nil,
ConnectionTimeout: time.Duration(connectionTimeout) * time.Second, ConnectionTimeout: time.Duration(connectionTimeout) * time.Second,
SyncPeriod: 0, Username: cmd.Flag("password").Value.String(),
Bucket: "", Password: cmd.Flag("username").Value.String(),
PersistConnection: false,
Username: username,
Password: password,
Token: "",
}, },
}, nil }, nil
} }

View File

@ -5,6 +5,7 @@ import "github.com/abronan/valkeyrie/store"
// Config FIXME // Config FIXME
type Config struct { type Config struct {
Backend store.Backend Backend store.Backend
Prefix string
Endpoints []string Endpoints []string
Options *store.Config Options *store.Config
} }

View File

@ -11,8 +11,7 @@ import (
"github.com/ldez/traefik-certs-dumper/dumper" "github.com/ldez/traefik-certs-dumper/dumper"
) )
// FIXME prefix const storeKey = "/acme/account/object"
const storeKey = "traefik/acme/account/object"
// Dump FIXME // Dump FIXME
func Dump(config *Config, baseConfig *dumper.BaseConfig) error { func Dump(config *Config, baseConfig *dumper.BaseConfig) error {
@ -21,7 +20,7 @@ func Dump(config *Config, baseConfig *dumper.BaseConfig) error {
return err return err
} }
pair, err := kvStore.Get(storeKey, nil) pair, err := kvStore.Get(config.Prefix+storeKey, nil)
if err != nil { if err != nil {
return err return err
} }