diff --git a/agent/agent.go b/agent/agent.go index d6b3eabe76..f11b717824 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -686,7 +686,7 @@ func (a *Agent) reloadWatches(cfg *config.RuntimeConfig) error { config.TLSConfig.Address = addr } - if err := wp.Run(addr, config); err != nil { + if err := wp.RunWithConfig(addr, config); err != nil { a.logger.Printf("[ERR] agent: Failed to run watch: %v", err) } }(wp) diff --git a/command/watch/watch.go b/command/watch/watch.go index 14e4701b8b..3b8c67836b 100644 --- a/command/watch/watch.go +++ b/command/watch/watch.go @@ -226,7 +226,7 @@ func (c *cmd) Run(args []string) int { }() // Run the watch - if err := wp.Run(c.http.Addr(), nil); err != nil { + if err := wp.Run(c.http.Addr()); err != nil { c.UI.Error(fmt.Sprintf("Error querying Consul agent: %s", err)) return 1 } diff --git a/watch/funcs_test.go b/watch/funcs_test.go index 35de2387aa..190ae24faa 100644 --- a/watch/funcs_test.go +++ b/watch/funcs_test.go @@ -64,7 +64,7 @@ func TestKeyWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr(), nil); err != nil { + if err := plan.Run(a.HTTPAddr()); err != nil { t.Fatalf("err: %v", err) } }() @@ -118,7 +118,7 @@ func TestKeyWatch_With_PrefixDelete(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr(), nil); err != nil { + if err := plan.Run(a.HTTPAddr()); err != nil { t.Fatalf("err: %v", err) } }() @@ -171,7 +171,7 @@ func TestKeyPrefixWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr(), nil); err != nil { + if err := plan.Run(a.HTTPAddr()); err != nil { t.Fatalf("err: %v", err) } }() @@ -225,7 +225,7 @@ func TestServicesWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr(), nil); err != nil { + if err := plan.Run(a.HTTPAddr()); err != nil { t.Fatalf("err: %v", err) } }() @@ -276,7 +276,7 @@ func TestNodesWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr(), nil); err != nil { + if err := plan.Run(a.HTTPAddr()); err != nil { t.Fatalf("err: %v", err) } }() @@ -332,7 +332,7 @@ func TestServiceWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr(), nil); err != nil { + if err := plan.Run(a.HTTPAddr()); err != nil { t.Fatalf("err: %v", err) } }() @@ -393,7 +393,7 @@ func TestChecksWatch_State(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr(), nil); err != nil { + if err := plan.Run(a.HTTPAddr()); err != nil { t.Fatalf("err: %v", err) } }() @@ -459,7 +459,7 @@ func TestChecksWatch_Service(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr(), nil); err != nil { + if err := plan.Run(a.HTTPAddr()); err != nil { t.Fatalf("err: %v", err) } }() @@ -510,7 +510,7 @@ func TestEventWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr(), nil); err != nil { + if err := plan.Run(a.HTTPAddr()); err != nil { t.Fatalf("err: %v", err) } }() diff --git a/watch/plan.go b/watch/plan.go index 2743518dac..fff9da7c7c 100644 --- a/watch/plan.go +++ b/watch/plan.go @@ -19,8 +19,12 @@ const ( maxBackoffTime = 180 * time.Second ) +func (p *Plan) Run(address string) error { + return p.RunWithConfig(address, nil) +} + // Run is used to run a watch plan -func (p *Plan) Run(address string, conf *consulapi.Config) error { +func (p *Plan) RunWithConfig(address string, conf *consulapi.Config) error { // Setup the client p.address = address if conf == nil { diff --git a/watch/plan_test.go b/watch/plan_test.go index c7b16fade0..16e4cfbc21 100644 --- a/watch/plan_test.go +++ b/watch/plan_test.go @@ -47,7 +47,7 @@ func TestRun_Stop(t *testing.T) { errCh := make(chan error, 1) go func() { - errCh <- plan.Run("127.0.0.1:8500", nil) + errCh <- plan.Run("127.0.0.1:8500") }() select {