From dbc407cec9eaea707cf3c8a8fbdae1d01631b828 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Wed, 27 Jun 2018 09:07:22 -0400 Subject: [PATCH] go fmt changes --- agent/catalog_endpoint_test.go | 44 ++++++++++++++++---------------- agent/consul/catalog_endpoint.go | 13 +++++----- agent/consul/client.go | 2 +- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/agent/catalog_endpoint_test.go b/agent/catalog_endpoint_test.go index ada7e2185..cef9cc061 100644 --- a/agent/catalog_endpoint_test.go +++ b/agent/catalog_endpoint_test.go @@ -8,11 +8,11 @@ import ( "time" "github.com/hashicorp/consul/agent/structs" - "github.com/hashicorp/consul/types" "github.com/hashicorp/consul/testutil/retry" + "github.com/hashicorp/consul/types" "github.com/hashicorp/serf/coordinate" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/require" ) func TestCatalogRegister_Service_InvalidAddress(t *testing.T) { @@ -112,31 +112,31 @@ func TestCatalogNodes(t *testing.T) { } func TestCatalog_RegisterNoID(t *testing.T) { - t.Parallel() - a := NewTestAgent(t.Name(), "") - defer a.Shutdown() + t.Parallel() + a := NewTestAgent(t.Name(), "") + defer a.Shutdown() - // Register node - args := &structs.RegisterRequest{ - Datacenter: "dc1", - Node: "foo", - Address: "127.0.0.1", - } + // Register node + args := &structs.RegisterRequest{ + Datacenter: "dc1", + Node: "foo", + Address: "127.0.0.1", + } - var out struct{} - require.NoError(t, a.RPC("Catalog.Register", args, &out)) + var out struct{} + require.NoError(t, a.RPC("Catalog.Register", args, &out)) - req, _ := http.NewRequest("GET", "/v1/catalog/node/foo", nil) - resp := httptest.NewRecorder() - obj, err := a.srv.CatalogNodeServices(resp, req) - require.NoError(t, err) + req, _ := http.NewRequest("GET", "/v1/catalog/node/foo", nil) + resp := httptest.NewRecorder() + obj, err := a.srv.CatalogNodeServices(resp, req) + require.NoError(t, err) - // Verify an index is set - assertIndex(t, resp) + // Verify an index is set + assertIndex(t, resp) - node := obj.(*structs.NodeServices) - - require.NotEqual(t, types.NodeID(""), node.Node.ID) + node := obj.(*structs.NodeServices) + + require.NotEqual(t, types.NodeID(""), node.Node.ID) } func TestCatalogNodes_MetaFilter(t *testing.T) { diff --git a/agent/consul/catalog_endpoint.go b/agent/consul/catalog_endpoint.go index ac17613fe..cc1e187e0 100644 --- a/agent/consul/catalog_endpoint.go +++ b/agent/consul/catalog_endpoint.go @@ -38,14 +38,13 @@ func (c *Catalog) Register(args *structs.RegisterRequest, reply *struct{}) error return fmt.Errorf("Bad node ID: %v", err) } } else { - id, err := uuid.GenerateUUID() - if err != nil { - return fmt.Errorf("Failed to generate ID: %v", err) - } - - args.ID = types.NodeID(id) - } + id, err := uuid.GenerateUUID() + if err != nil { + return fmt.Errorf("Failed to generate ID: %v", err) + } + args.ID = types.NodeID(id) + } // Fetch the ACL token, if any. rule, err := c.srv.resolveToken(args.Token) diff --git a/agent/consul/client.go b/agent/consul/client.go index 000cb66f8..f6b123a31 100644 --- a/agent/consul/client.go +++ b/agent/consul/client.go @@ -134,7 +134,7 @@ func NewClientLogger(config *Config, logger *log.Logger) (*Client, error) { shutdownCh: make(chan struct{}), } - c.rpcLimiter.Store(rate.NewLimiter(config.RPCRate, config.RPCMaxBurst)) + c.rpcLimiter.Store(rate.NewLimiter(config.RPCRate, config.RPCMaxBurst)) if err := c.initEnterprise(); err != nil { c.Shutdown()