command/server: config for setting stats addresses

This commit is contained in:
Mitchell Hashimoto 2015-04-17 11:21:40 -07:00
parent b5fbc293b3
commit 75a319d767
3 changed files with 14 additions and 4 deletions

View file

@ -14,10 +14,10 @@ import (
// Config is the configuration for the vault server.
type Config struct {
Listeners []*Listener
Backend *Backend
StatsiteAddr string // TODO: Parse this
StatsdAddr string // TODO: Parse this
Listeners []*Listener `hcl:"-"`
Backend *Backend `hcl:"-"`
StatsiteAddr string `hcl:"statsite_addr"`
StatsdAddr string `hcl:"statsd_addr"`
}
// DevConfig is a Config that is used for dev mode of Vault.
@ -114,6 +114,10 @@ func LoadConfigFile(path string) (*Config, error) {
// Start building the result
var result Config
if err := hcl.DecodeObject(&result, obj); err != nil {
return nil, err
}
if objs := obj.Get("listener", false); objs != nil {
result.Listeners, err = loadListeners(objs)
if err != nil {

View file

@ -27,6 +27,9 @@ func TestLoadConfigFile(t *testing.T) {
"foo": "bar",
},
},
StatsiteAddr: "foo",
StatsdAddr: "bar",
}
if !reflect.DeepEqual(config, expected) {
t.Fatalf("bad: %#v", config)

View file

@ -1,3 +1,6 @@
statsd_addr = "bar"
statsite_addr = "foo"
listener "tcp" {
address = "127.0.0.1:443"
}