mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #5902 from mitake/bench-auth
tools: add --user for auth in benchmarks
This commit is contained in:
commit
4bc29e2b9c
@ -46,6 +46,8 @@ var (
|
|||||||
|
|
||||||
cpuProfPath string
|
cpuProfPath string
|
||||||
memProfPath string
|
memProfPath string
|
||||||
|
|
||||||
|
user string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -57,4 +59,6 @@ func init() {
|
|||||||
RootCmd.PersistentFlags().StringVar(&tls.CertFile, "cert", "", "identify HTTPS client using this SSL certificate file")
|
RootCmd.PersistentFlags().StringVar(&tls.CertFile, "cert", "", "identify HTTPS client using this SSL certificate file")
|
||||||
RootCmd.PersistentFlags().StringVar(&tls.KeyFile, "key", "", "identify HTTPS client using this SSL key file")
|
RootCmd.PersistentFlags().StringVar(&tls.KeyFile, "key", "", "identify HTTPS client using this SSL key file")
|
||||||
RootCmd.PersistentFlags().StringVar(&tls.CAFile, "cacert", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
|
RootCmd.PersistentFlags().StringVar(&tls.CAFile, "cacert", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
|
||||||
|
|
||||||
|
RootCmd.PersistentFlags().StringVar(&user, "user", "", "specify username and password in username:password format")
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/coreos/etcd/clientv3"
|
"github.com/coreos/etcd/clientv3"
|
||||||
)
|
)
|
||||||
@ -41,6 +42,17 @@ func mustCreateConn() *clientv3.Client {
|
|||||||
cfg.TLS = cfgtls
|
cfg.TLS = cfgtls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(user) != 0 {
|
||||||
|
splitted := strings.SplitN(user, ":", 2)
|
||||||
|
if len(splitted) != 2 {
|
||||||
|
fmt.Fprintf(os.Stderr, "bad user information: %s\n", user)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg.Username = splitted[0]
|
||||||
|
cfg.Password = splitted[1]
|
||||||
|
}
|
||||||
|
|
||||||
client, err := clientv3.New(cfg)
|
client, err := clientv3.New(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "dial error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "dial error: %v\n", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user