This commit is contained in:
Fernandez Ludovic 2019-04-20 15:47:19 +02:00
parent b2407882e7
commit 7fd60035e7

View File

@ -1,8 +1,12 @@
package cmd package cmd
import ( import (
"fmt" "strconv"
"github.com/abronan/valkeyrie/store"
"github.com/abronan/valkeyrie/store/zookeeper"
"github.com/ldez/traefik-certs-dumper/dumper"
"github.com/ldez/traefik-certs-dumper/dumper/kv"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -11,12 +15,38 @@ var zookeeperCmd = &cobra.Command{
Use: "zookeeper", Use: "zookeeper",
Short: "TODO", Short: "TODO",
Long: `TODO`, Long: `TODO`,
RunE: func(cmd *cobra.Command, args []string) error { RunE: zookeeperRun,
fmt.Println("zookeeper called")
return nil
},
} }
func init() { func init() {
kvCmd.AddCommand(zookeeperCmd) kvCmd.AddCommand(zookeeperCmd)
} }
func zookeeperRun(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.Backend = store.ZK
zookeeper.Register()
return kv.Dump(config, dumpPath, crtInfo, keyInfo, subDir)
}