feat(kv): support suffix/storage

This commit is contained in:
Fernandez Ludovic 2019-10-09 02:43:07 +02:00
parent 867c59b8fb
commit 072d407807
11 changed files with 18 additions and 10 deletions

View File

@ -26,6 +26,7 @@ func init() {
kvCmd.PersistentFlags().StringSlice("endpoints", []string{"localhost:8500"}, "List of endpoints.")
kvCmd.PersistentFlags().Int("connection-timeout", 0, "Connection timeout in seconds.")
kvCmd.PersistentFlags().String("prefix", "traefik", "Prefix used for KV store.")
kvCmd.PersistentFlags().String("suffix", kv.DefaultStoreKeySuffix, "Suffix/Storage used for KV store.")
kvCmd.PersistentFlags().String("password", "", "Password for connection.")
kvCmd.PersistentFlags().String("username", "", "Username for connection.")
@ -56,6 +57,7 @@ func getKvConfig(cmd *cobra.Command) (*kv.Config, error) {
return &kv.Config{
Endpoints: endpoints,
Prefix: cmd.Flag("prefix").Value.String(),
Suffix: cmd.Flag("suffix").Value.String(),
Options: &store.Config{
ConnectionTimeout: time.Duration(connectionTimeout) * time.Second,
Username: cmd.Flag("password").Value.String(),

View File

@ -28,4 +28,4 @@ Dump Let's Encrypt certificates from Traefik.
* [traefik-certs-dumper kv](traefik-certs-dumper_kv.md) - Dump the content of a KV store.
* [traefik-certs-dumper version](traefik-certs-dumper_version.md) - Display version
###### Auto generated by spf13/cobra on 1-Sep-2019
###### Auto generated by spf13/cobra on 9-Oct-2019

View File

@ -37,4 +37,4 @@ traefik-certs-dumper file [flags]
* [traefik-certs-dumper](traefik-certs-dumper.md) - Dump Let's Encrypt certificates from Traefik.
###### Auto generated by spf13/cobra on 1-Sep-2019
###### Auto generated by spf13/cobra on 9-Oct-2019

View File

@ -14,6 +14,7 @@ Dump the content of a KV store.
-h, --help help for kv
--password string Password for connection.
--prefix string Prefix used for KV store. (default "traefik")
--suffix string Suffix/Storage used for KV store. (default "/acme/account/object")
--tls Enable TLS encryption.
--tls.ca string Root CA for certificate verification if TLS is enabled
--tls.ca.optional
@ -46,4 +47,4 @@ Dump the content of a KV store.
* [traefik-certs-dumper kv etcd](traefik-certs-dumper_kv_etcd.md) - Dump the content of etcd.
* [traefik-certs-dumper kv zookeeper](traefik-certs-dumper_kv_zookeeper.md) - Dump the content of zookeeper.
###### Auto generated by spf13/cobra on 1-Sep-2019
###### Auto generated by spf13/cobra on 9-Oct-2019

View File

@ -34,6 +34,7 @@ traefik-certs-dumper kv boltdb [flags]
--password string Password for connection.
--post-hook string Execute a command only if changes occurs on the data source. (works only with the watch mode)
--prefix string Prefix used for KV store. (default "traefik")
--suffix string Suffix/Storage used for KV store. (default "/acme/account/object")
--tls Enable TLS encryption.
--tls.ca string Root CA for certificate verification if TLS is enabled
--tls.ca.optional
@ -48,4 +49,4 @@ traefik-certs-dumper kv boltdb [flags]
* [traefik-certs-dumper kv](traefik-certs-dumper_kv.md) - Dump the content of a KV store.
###### Auto generated by spf13/cobra on 1-Sep-2019
###### Auto generated by spf13/cobra on 9-Oct-2019

View File

@ -33,6 +33,7 @@ traefik-certs-dumper kv consul [flags]
--password string Password for connection.
--post-hook string Execute a command only if changes occurs on the data source. (works only with the watch mode)
--prefix string Prefix used for KV store. (default "traefik")
--suffix string Suffix/Storage used for KV store. (default "/acme/account/object")
--tls Enable TLS encryption.
--tls.ca string Root CA for certificate verification if TLS is enabled
--tls.ca.optional
@ -47,4 +48,4 @@ traefik-certs-dumper kv consul [flags]
* [traefik-certs-dumper kv](traefik-certs-dumper_kv.md) - Dump the content of a KV store.
###### Auto generated by spf13/cobra on 1-Sep-2019
###### Auto generated by spf13/cobra on 9-Oct-2019

View File

@ -33,6 +33,7 @@ traefik-certs-dumper kv etcd [flags]
--password string Password for connection.
--post-hook string Execute a command only if changes occurs on the data source. (works only with the watch mode)
--prefix string Prefix used for KV store. (default "traefik")
--suffix string Suffix/Storage used for KV store. (default "/acme/account/object")
--tls Enable TLS encryption.
--tls.ca string Root CA for certificate verification if TLS is enabled
--tls.ca.optional
@ -47,4 +48,4 @@ traefik-certs-dumper kv etcd [flags]
* [traefik-certs-dumper kv](traefik-certs-dumper_kv.md) - Dump the content of a KV store.
###### Auto generated by spf13/cobra on 1-Sep-2019
###### Auto generated by spf13/cobra on 9-Oct-2019

View File

@ -32,6 +32,7 @@ traefik-certs-dumper kv zookeeper [flags]
--password string Password for connection.
--post-hook string Execute a command only if changes occurs on the data source. (works only with the watch mode)
--prefix string Prefix used for KV store. (default "traefik")
--suffix string Suffix/Storage used for KV store. (default "/acme/account/object")
--tls Enable TLS encryption.
--tls.ca string Root CA for certificate verification if TLS is enabled
--tls.ca.optional
@ -46,4 +47,4 @@ traefik-certs-dumper kv zookeeper [flags]
* [traefik-certs-dumper kv](traefik-certs-dumper_kv.md) - Dump the content of a KV store.
###### Auto generated by spf13/cobra on 1-Sep-2019
###### Auto generated by spf13/cobra on 9-Oct-2019

View File

@ -35,4 +35,4 @@ traefik-certs-dumper version [flags]
* [traefik-certs-dumper](traefik-certs-dumper.md) - Dump Let's Encrypt certificates from Traefik.
###### Auto generated by spf13/cobra on 1-Sep-2019
###### Auto generated by spf13/cobra on 9-Oct-2019

View File

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

View File

@ -17,7 +17,7 @@ import (
"github.com/ldez/traefik-certs-dumper/v2/hook"
)
const storeKeySuffix = "/acme/account/object"
const DefaultStoreKeySuffix = "/acme/account/object"
// Dump Dumps KV content to certificates.
func Dump(config *Config, baseConfig *dumper.BaseConfig) error {
@ -26,7 +26,7 @@ func Dump(config *Config, baseConfig *dumper.BaseConfig) error {
return fmt.Errorf("unable to create client of the store: %v", err)
}
storeKey := config.Prefix + storeKeySuffix
storeKey := config.Prefix + config.Suffix
if baseConfig.Watch {
return watch(kvStore, storeKey, baseConfig)