diff --git a/main.go b/main.go index b1a5f6aff5..d466675ba7 100644 --- a/main.go +++ b/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) diff --git a/subnet/registry.go b/subnet/registry.go index 5f09bf3692..5ee410d117 100644 --- a/subnet/registry.go +++ b/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