Skip to content

Commit

Permalink
Merge pull request #409 from sittercity/etcd-auth
Browse files Browse the repository at this point in the history
Add cli args for etcd basic auth
  • Loading branch information
tomdee committed May 24, 2016
2 parents 5d0f023 + 455ebd3 commit 186b85a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type CmdLineOpts struct {
etcdKeyfile string
etcdCertfile string
etcdCAFile string
etcdUsername string
etcdPassword string
help bool
version bool
listen string
Expand All @@ -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")
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions subnet/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 186b85a

Please sign in to comment.