boltdb: WIP.

This commit is contained in:
Fernandez Ludovic 2019-04-20 15:46:56 +02:00
parent 38f5b7763f
commit f3e10c8489

View File

@ -1,8 +1,12 @@
package cmd
import (
"fmt"
"strconv"
"github.com/abronan/valkeyrie/store"
"github.com/abronan/valkeyrie/store/boltdb"
"github.com/ldez/traefik-certs-dumper/dumper"
"github.com/ldez/traefik-certs-dumper/dumper/kv"
"github.com/spf13/cobra"
)
@ -11,10 +15,7 @@ var boltdbCmd = &cobra.Command{
Use: "boltdb",
Short: "TODO",
Long: `TODO`,
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("boltdb called")
return nil
},
RunE: boltdbRun,
}
func init() {
@ -23,3 +24,35 @@ func init() {
boltdbCmd.Flags().Bool("persist-connection", false, "Persist connection for boltdb.")
boltdbCmd.Flags().String("bucket", "traefik", "Bucket for boltdb.")
}
func boltdbRun(cmd *cobra.Command, _ []string) error {
// FIXME shared with file and all KVs
dumpPath := cmd.Flag("dest").Value.String()
crtInfo := dumper.FileInfo{
Name: cmd.Flag("crt-name").Value.String(),
Ext: cmd.Flag("crt-ext").Value.String(),
}
keyInfo := dumper.FileInfo{
Name: cmd.Flag("key-name").Value.String(),
Ext: cmd.Flag("key-ext").Value.String(),
}
subDir, _ := strconv.ParseBool(cmd.Flag("domain-subdir").Value.String())
// ---
config, err := getBaseConfig(cmd)
if err != nil {
return err
}
config.Options.Bucket = cmd.Flag("bucket").Value.String()
config.Options.PersistConnection, _ = cmd.Flags().GetBool("persist-connection")
config.Backend = store.BOLTDB
boltdb.Register()
return kv.Dump(config, dumpPath, crtInfo, keyInfo, subDir)
}