Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cli args for etcd basic auth #409

Merged
merged 1 commit into from
May 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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