From 2605b8e27c20e380da569be81191480473f3fedf Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 23 Apr 2014 12:36:49 -0700 Subject: [PATCH] agent: Adding UiDir config param --- command/agent/config.go | 7 +++++++ command/agent/config_test.go | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/command/agent/config.go b/command/agent/config.go index 7dfd2a9456..b098362b48 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -124,6 +124,10 @@ type Config struct { // addresses, then the agent will error and exit. StartJoin []string `mapstructure:"start_join"` + // UiDir is the directory containing the Web UI resources. + // If provided, the UI endpoints will be enabled. + UiDir string `mapstructure:"ui_dir"` + // AEInterval controls the anti-entropy interval. This is how often // the agent attempts to reconcile it's local state with the server' // representation of our state. Defaults to every 60s. @@ -416,6 +420,9 @@ func MergeConfig(a, b *Config) *Config { if b.Ports.Server != 0 { result.Ports.Server = b.Ports.Server } + if b.UiDir != "" { + result.UiDir = b.UiDir + } // Copy the start join addresses result.StartJoin = make([]string, 0, len(a.StartJoin)+len(b.StartJoin)) diff --git a/command/agent/config_test.go b/command/agent/config_test.go index 3d7f26593c..a5ef9f932a 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -246,6 +246,17 @@ func TestDecodeConfig(t *testing.T) { if config.StartJoin[1] != "2.2.2.2" { t.Fatalf("bad: %#v", config) } + + // UI Dir + input = `{"ui_dir": "/opt/consul-ui"}` + config, err = DecodeConfig(bytes.NewReader([]byte(input))) + if err != nil { + t.Fatalf("err: %s", err) + } + + if config.UiDir != "/opt/consul-ui" { + t.Fatalf("bad: %#v", config) + } } func TestDecodeConfig_Service(t *testing.T) { @@ -377,6 +388,7 @@ func TestMergeConfig(t *testing.T) { Checks: []*CheckDefinition{nil}, Services: []*ServiceDefinition{nil}, StartJoin: []string{"1.1.1.1"}, + UiDir: "/opt/consul-ui", } c := MergeConfig(a, b)