add and test -advertise-wan cli flag

This commit is contained in:
pepov 2015-03-28 15:48:06 +01:00
parent 8abcf3d541
commit 8da6d4f065
2 changed files with 27 additions and 0 deletions

View File

@ -80,6 +80,7 @@ func (c *Command) readConfig() *Config {
cmdFlags.StringVar(&cmdConfig.ClientAddr, "client", "", "address to bind client listeners to (DNS, HTTP, HTTPS, RPC)") cmdFlags.StringVar(&cmdConfig.ClientAddr, "client", "", "address to bind client listeners to (DNS, HTTP, HTTPS, RPC)")
cmdFlags.StringVar(&cmdConfig.BindAddr, "bind", "", "address to bind server listeners to") cmdFlags.StringVar(&cmdConfig.BindAddr, "bind", "", "address to bind server listeners to")
cmdFlags.StringVar(&cmdConfig.AdvertiseAddr, "advertise", "", "address to advertise instead of bind addr") cmdFlags.StringVar(&cmdConfig.AdvertiseAddr, "advertise", "", "address to advertise instead of bind addr")
cmdFlags.StringVar(&cmdConfig.AdvertiseAddrWan, "advertise-wan", "", "address to advertise on wan instead of bind or advertise addr")
cmdFlags.StringVar(&cmdConfig.AtlasInfrastructure, "atlas", "", "infrastructure name in Atlas") cmdFlags.StringVar(&cmdConfig.AtlasInfrastructure, "atlas", "", "infrastructure name in Atlas")
cmdFlags.StringVar(&cmdConfig.AtlasToken, "atlas-token", "", "authentication token for Atlas") cmdFlags.StringVar(&cmdConfig.AtlasToken, "atlas-token", "", "authentication token for Atlas")

View File

@ -106,6 +106,32 @@ func TestRetryJoin(t *testing.T) {
}) })
} }
func TestReadCliConfig(t *testing.T) {
shutdownCh := make(chan struct{})
defer close(shutdownCh)
tmpDir, err := ioutil.TempDir("", "consul")
if err != nil {
t.Fatalf("err: %s", err)
}
cmd := &Command{
args: []string{
"-data-dir", tmpDir,
"-node", `"a"`,
"-advertise-wan", "1.2.3.4",
},
ShutdownCh: shutdownCh,
Ui: new(cli.MockUi),
}
config := cmd.readConfig()
if config.AdvertiseAddrWan != "1.2.3.4" {
t.Fatalf("expected -advertise-addr-wan 1.2.3.4 got %s", config.AdvertiseAddrWan)
}
}
func TestRetryJoinFail(t *testing.T) { func TestRetryJoinFail(t *testing.T) {
conf := nextConfig() conf := nextConfig()
tmpDir, err := ioutil.TempDir("", "consul") tmpDir, err := ioutil.TempDir("", "consul")