mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #4663 from gyuho/endpoints
etcdctlv3: use string slice for endpoints
This commit is contained in:
commit
679b40bc77
@ -28,8 +28,9 @@ import (
|
|||||||
// GlobalFlags are flags that defined globally
|
// GlobalFlags are flags that defined globally
|
||||||
// and are inherited to all sub-commands.
|
// and are inherited to all sub-commands.
|
||||||
type GlobalFlags struct {
|
type GlobalFlags struct {
|
||||||
Endpoints string
|
Endpoints []string
|
||||||
TLS transport.TLSInfo
|
|
||||||
|
TLS transport.TLSInfo
|
||||||
|
|
||||||
OutputFormat string
|
OutputFormat string
|
||||||
IsHex bool
|
IsHex bool
|
||||||
@ -38,7 +39,7 @@ type GlobalFlags struct {
|
|||||||
var display printer = &simplePrinter{}
|
var display printer = &simplePrinter{}
|
||||||
|
|
||||||
func mustClientFromCmd(cmd *cobra.Command) *clientv3.Client {
|
func mustClientFromCmd(cmd *cobra.Command) *clientv3.Client {
|
||||||
endpoint, err := cmd.Flags().GetString("endpoint")
|
endpoints, err := cmd.Flags().GetStringSlice("endpoints")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ExitWithError(ExitError, err)
|
ExitWithError(ExitError, err)
|
||||||
}
|
}
|
||||||
@ -68,10 +69,10 @@ func mustClientFromCmd(cmd *cobra.Command) *clientv3.Client {
|
|||||||
ExitWithError(ExitBadFeature, errors.New("unsupported output format"))
|
ExitWithError(ExitBadFeature, errors.New("unsupported output format"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return mustClient(endpoint, cert, key, cacert)
|
return mustClient(endpoints, cert, key, cacert)
|
||||||
}
|
}
|
||||||
|
|
||||||
func mustClient(endpoint, cert, key, cacert string) *clientv3.Client {
|
func mustClient(endpoints []string, cert, key, cacert string) *clientv3.Client {
|
||||||
// set tls if any one tls option set
|
// set tls if any one tls option set
|
||||||
var cfgtls *transport.TLSInfo
|
var cfgtls *transport.TLSInfo
|
||||||
tls := transport.TLSInfo{}
|
tls := transport.TLSInfo{}
|
||||||
@ -92,7 +93,7 @@ func mustClient(endpoint, cert, key, cacert string) *clientv3.Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cfg := clientv3.Config{
|
cfg := clientv3.Config{
|
||||||
Endpoints: []string{endpoint},
|
Endpoints: endpoints,
|
||||||
TLS: cfgtls,
|
TLS: cfgtls,
|
||||||
DialTimeout: 20 * time.Second,
|
DialTimeout: 20 * time.Second,
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ func makeMirrorCommandFunc(cmd *cobra.Command, args []string) {
|
|||||||
ExitWithError(ExitBadArgs, errors.New("make-mirror takes one destination arguement."))
|
ExitWithError(ExitBadArgs, errors.New("make-mirror takes one destination arguement."))
|
||||||
}
|
}
|
||||||
|
|
||||||
dc := mustClient(args[0], mmcert, mmkey, mmcacert)
|
dc := mustClient([]string{args[0]}, mmcert, mmkey, mmcacert)
|
||||||
c := mustClientFromCmd(cmd)
|
c := mustClientFromCmd(cmd)
|
||||||
|
|
||||||
err := makeMirror(context.TODO(), c, dc)
|
err := makeMirror(context.TODO(), c, dc)
|
||||||
|
@ -41,7 +41,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.PersistentFlags().StringVar(&globalFlags.Endpoints, "endpoint", "127.0.0.1:2378", "gRPC endpoint")
|
rootCmd.PersistentFlags().StringSliceVar(&globalFlags.Endpoints, "endpoints", []string{"127.0.0.1:2378", "127.0.0.1:22378", "127.0.0.1:32378"}, "gRPC endpoints")
|
||||||
|
|
||||||
rootCmd.PersistentFlags().StringVarP(&globalFlags.OutputFormat, "write-out", "w", "simple", "set the output format (simple, json, protobuf)")
|
rootCmd.PersistentFlags().StringVarP(&globalFlags.OutputFormat, "write-out", "w", "simple", "set the output format (simple, json, protobuf)")
|
||||||
rootCmd.PersistentFlags().BoolVar(&globalFlags.IsHex, "hex", false, "print byte strings as hex encoded strings")
|
rootCmd.PersistentFlags().BoolVar(&globalFlags.IsHex, "hex", false, "print byte strings as hex encoded strings")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user