ソースを参照

Add cli args for etcd basic auth

Shane Gibbs 9 年 前
コミット
455ebd3bb9
2 ファイル変更10 行追加0 行削除
  1. 6 0
      main.go
  2. 4 0
      subnet/registry.go

+ 6 - 0
main.go

@@ -47,6 +47,8 @@ type CmdLineOpts struct {
 	etcdKeyfile    string
 	etcdCertfile   string
 	etcdCAFile     string
+	etcdUsername   string
+	etcdPassword   string
 	help           bool
 	version        bool
 	listen         string
@@ -64,6 +66,8 @@ func init() {
 	flag.StringVar(&opts.etcdKeyfile, "etcd-keyfile", "", "SSL key file used to secure etcd communication")
 	flag.StringVar(&opts.etcdCertfile, "etcd-certfile", "", "SSL certification file used to secure etcd communication")
 	flag.StringVar(&opts.etcdCAFile, "etcd-cafile", "", "SSL Certificate Authority file used to secure etcd communication")
+	flag.StringVar(&opts.etcdUsername, "etcd-username", "", "Username for BasicAuth to etcd")
+	flag.StringVar(&opts.etcdPassword, "etcd-password", "", "Password for BasicAuth to etcd")
 	flag.StringVar(&opts.listen, "listen", "", "run as server and listen on specified address (e.g. ':8080')")
 	flag.StringVar(&opts.remote, "remote", "", "run as client and connect to server on specified address (e.g. '10.1.2.3:8080')")
 	flag.StringVar(&opts.remoteKeyfile, "remote-keyfile", "", "SSL key file used to secure client/server communication")
@@ -84,6 +88,8 @@ func newSubnetManager() (subnet.Manager, error) {
 		Certfile:  opts.etcdCertfile,
 		CAFile:    opts.etcdCAFile,
 		Prefix:    opts.etcdPrefix,
+		Username:  opts.etcdUsername,
+		Password:  opts.etcdPassword,
 	}
 
 	return subnet.NewLocalManager(cfg)

+ 4 - 0
subnet/registry.go

@@ -55,6 +55,8 @@ type EtcdConfig struct {
 	Certfile  string
 	CAFile    string
 	Prefix    string
+	Username  string
+	Password  string
 }
 
 type etcdNewFunc func(c *EtcdConfig) (etcd.KeysAPI, error)
@@ -82,6 +84,8 @@ func newEtcdClient(c *EtcdConfig) (etcd.KeysAPI, error) {
 	cli, err := etcd.New(etcd.Config{
 		Endpoints: c.Endpoints,
 		Transport: t,
+		Username:  c.Username,
+		Password:  c.Password,
 	})
 	if err != nil {
 		return nil, err