Skip to content

Commit

Permalink
Adding Consul configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed Apr 27, 2014
1 parent c8e465f commit d41aa4f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var (
clientCaKeys string
config Config // holds the global confd config.
confdir string
consul bool
consulAddr string
debug bool
etcdNodes Nodes
etcdScheme string
Expand All @@ -44,6 +46,8 @@ type confd struct {
ClientKey string `toml:"client_key"`
ClientCaKeys string `toml:"client_cakeys"`
ConfDir string `toml:"confdir"`
Consul bool `toml:"consul"`
ConsulAddr string `toml:"consul_addr"`
EtcdNodes []string `toml:"etcd_nodes"`
EtcdScheme string `toml:"etcd_scheme"`
Interval int `toml:"interval"`
Expand All @@ -60,6 +64,8 @@ func init() {
flag.StringVar(&clientKey, "client-key", "", "the client key")
flag.StringVar(&clientCaKeys, "client-ca-keys", "", "client ca keys")
flag.StringVar(&confdir, "confdir", "/etc/confd", "confd conf directory")
flag.BoolVar(&consul, "consul", false, "specified to enable use of Consul")
flag.StringVar(&consulAddr, "consul-addr", "", "address of Consul HTTP interface")
flag.Var(&etcdNodes, "node", "list of etcd nodes")
flag.StringVar(&etcdScheme, "etcd-scheme", "http", "the etcd URI scheme. (http or https)")
flag.IntVar(&interval, "interval", 600, "etcd polling interval")
Expand Down Expand Up @@ -113,7 +119,7 @@ func ClientKey() string {

// ClientCaKeys returns the client CA certificates
func ClientCaKeys() string {
return config.Confd.ClientCaKeys
return config.Confd.ClientCaKeys
}

// ConfDir returns the path to the confd config dir.
Expand All @@ -126,6 +132,16 @@ func ConfigDir() string {
return filepath.Join(config.Confd.ConfDir, "conf.d")
}

// Consul returns if we should use Consul
func Consul() bool {
return config.Confd.Consul
}

// ConsulAddr returns the address of the consul node
func ConsulAddr() string {
return config.Confd.ConsulAddr
}

// EtcdNodes returns a list of etcd node url strings.
// For example: ["http://203.0.113.30:4001"]
func EtcdNodes() []string {
Expand Down Expand Up @@ -186,6 +202,7 @@ func setDefaults() {
config = Config{
Confd: confd{
ConfDir: "/etc/confd",
ConsulAddr: "127.0.0.1:8500",
Interval: 600,
Prefix: "/",
EtcdNodes: []string{"127.0.0.1:4001"},
Expand Down Expand Up @@ -262,6 +279,10 @@ func setConfigFromFlag(f *flag.Flag) {
config.Confd.ClientCaKeys = clientCaKeys
case "confdir":
config.Confd.ConfDir = confdir
case "consul":
config.Confd.Consul = consul
case "consul-addr":
config.Confd.ConsulAddr = consulAddr
case "node":
config.Confd.EtcdNodes = etcdNodes
case "etcd-scheme":
Expand Down

0 comments on commit d41aa4f

Please sign in to comment.