Basic Auth support for Etcd.

Fixes #859
This commit is contained in:
Chi Vinh Le 2015-12-17 12:48:13 +01:00
parent 048f1284e4
commit a090caf2c3

View file

@ -4,6 +4,7 @@ import (
"encoding/base64"
"errors"
"net/url"
"os"
"path/filepath"
"strings"
"sync"
@ -121,6 +122,22 @@ func newEtcdBackend(conf map[string]string) (Backend, error) {
Transport: cTransport,
}
// Set credentials.
username := os.Getenv("ETCD_USERNAME")
if username == "" {
username, _ = conf["username"]
}
password := os.Getenv("ETCD_PASSWORD")
if password == "" {
password, _ = conf["password"]
}
if username != "" && password != "" {
cfg.Username = username
cfg.Password = password
}
c, err := client.New(cfg)
if err != nil {
return nil, err