From ecfe5ad331224a535bbb2f6af3c89c79f42cfc65 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 20 Apr 2019 14:26:25 +0200 Subject: [PATCH] chore: add KV options. --- cmd/boltdb.go | 14 ++++---------- cmd/consul.go | 13 +++---------- cmd/etcd.go | 13 +++---------- cmd/kv.go | 18 ++++++++---------- cmd/zookeeper.go | 13 ++----------- 5 files changed, 20 insertions(+), 51 deletions(-) diff --git a/cmd/boltdb.go b/cmd/boltdb.go index 8f5c976..f3ec36b 100644 --- a/cmd/boltdb.go +++ b/cmd/boltdb.go @@ -11,21 +11,15 @@ var boltdbCmd = &cobra.Command{ Use: "boltdb", Short: "TODO", Long: `TODO`, - Run: func(cmd *cobra.Command, args []string) { + RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("boltdb called") + return nil }, } func init() { kvCmd.AddCommand(boltdbCmd) - // Here you will define your flags and configuration settings. - - // Cobra supports Persistent Flags which will work for this command - // and all subcommands, e.g.: - // boltdbCmd.PersistentFlags().String("foo", "", "A help for foo") - - // Cobra supports local flags which will only run when this command - // is called directly, e.g.: - // boltdbCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + boltdbCmd.Flags().Bool("persist-connection", false, "Persist connection for boltdb.") + boltdbCmd.Flags().String("bucket", "traefik", "Bucket for boltdb.") } diff --git a/cmd/consul.go b/cmd/consul.go index 231cd69..7296fe3 100644 --- a/cmd/consul.go +++ b/cmd/consul.go @@ -11,21 +11,14 @@ var consulCmd = &cobra.Command{ Use: "consul", Short: "TODO", Long: `TODO`, - Run: func(cmd *cobra.Command, args []string) { + RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("consul called") + return nil }, } func init() { kvCmd.AddCommand(consulCmd) - // Here you will define your flags and configuration settings. - - // Cobra supports Persistent Flags which will work for this command - // and all subcommands, e.g.: - // consulCmd.PersistentFlags().String("foo", "", "A help for foo") - - // Cobra supports local flags which will only run when this command - // is called directly, e.g.: - // consulCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + consulCmd.Flags().String("token", "", "Token for consul.") } diff --git a/cmd/etcd.go b/cmd/etcd.go index 4dcc1b6..814d699 100644 --- a/cmd/etcd.go +++ b/cmd/etcd.go @@ -11,21 +11,14 @@ var etcdCmd = &cobra.Command{ Use: "etcd", Short: "TODO", Long: `TODO`, - Run: func(cmd *cobra.Command, args []string) { + RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("etcd called") + return nil }, } func init() { kvCmd.AddCommand(etcdCmd) - // Here you will define your flags and configuration settings. - - // Cobra supports Persistent Flags which will work for this command - // and all subcommands, e.g.: - // etcdCmd.PersistentFlags().String("foo", "", "A help for foo") - - // Cobra supports local flags which will only run when this command - // is called directly, e.g.: - // etcdCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + etcdCmd.Flags().Int("sync-period", 0, "Sync period for etcd in seconds.") } diff --git a/cmd/kv.go b/cmd/kv.go index a0f8147..ddedbd3 100644 --- a/cmd/kv.go +++ b/cmd/kv.go @@ -1,5 +1,3 @@ -// Copyright © 2019 ldez - package cmd import ( @@ -16,13 +14,13 @@ var kvCmd = &cobra.Command{ func init() { rootCmd.AddCommand(kvCmd) - // Here you will define your flags and configuration settings. + kvCmd.PersistentFlags().StringSlice("endpoints", []string{"localhost:8500"}, "Comma separated list of endpoints.") + kvCmd.PersistentFlags().Int("connection-timeout", 0, "Connection timeout in seconds.") + kvCmd.PersistentFlags().String("password", "", "Password for connection.") + kvCmd.PersistentFlags().String("username", "", "Username for connection.") - // Cobra supports Persistent Flags which will work for this command - // and all subcommands, e.g.: - // kvCmd.PersistentFlags().String("foo", "", "A help for foo") - - // Cobra supports local flags which will only run when this command - // is called directly, e.g.: - // kvCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + // FIXME review TLS parts + kvCmd.PersistentFlags().Bool("tls.enable", false, "Enable TLS encryption.") + kvCmd.PersistentFlags().Bool("tls.insecureskipverify", false, "Trust unverified certificates if TLS is enabled.") + kvCmd.PersistentFlags().String("tls.ca-cert-file", "", "Root CA file for certificate verification if TLS is enabled.") } diff --git a/cmd/zookeeper.go b/cmd/zookeeper.go index d53ede3..7c7ed73 100644 --- a/cmd/zookeeper.go +++ b/cmd/zookeeper.go @@ -11,21 +11,12 @@ var zookeeperCmd = &cobra.Command{ Use: "zookeeper", Short: "TODO", Long: `TODO`, - Run: func(cmd *cobra.Command, args []string) { + RunE: func(cmd *cobra.Command, args []string) error { fmt.Println("zookeeper called") + return nil }, } func init() { kvCmd.AddCommand(zookeeperCmd) - - // Here you will define your flags and configuration settings. - - // Cobra supports Persistent Flags which will work for this command - // and all subcommands, e.g.: - // zookeeperCmd.PersistentFlags().String("foo", "", "A help for foo") - - // Cobra supports local flags which will only run when this command - // is called directly, e.g.: - // zookeeperCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") }