From 3b82ad09552853b94f27b28d6d264d01958caceb Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 5 Aug 2020 13:20:12 -0400 Subject: [PATCH] Rename NewClient/NewServer Now that duplicate constructors have been removed we can use the shorter names for the single constructor. --- agent/agent.go | 4 ++-- agent/consul/client.go | 3 ++- agent/consul/leader_test.go | 2 +- agent/consul/server.go | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 021b20292c..74440efd6e 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -695,13 +695,13 @@ func (a *Agent) Start(ctx context.Context) error { // Setup either the client or the server. if c.ServerMode { - server, err := consul.NewServerWithOptions(consulCfg, options...) + server, err := consul.NewServer(consulCfg, options...) if err != nil { return fmt.Errorf("Failed to start Consul server: %v", err) } a.delegate = server } else { - client, err := consul.NewClientWithOptions(consulCfg, options...) + client, err := consul.NewClient(consulCfg, options...) if err != nil { return fmt.Errorf("Failed to start Consul client: %v", err) } diff --git a/agent/consul/client.go b/agent/consul/client.go index 8b415f5500..8d3786a421 100644 --- a/agent/consul/client.go +++ b/agent/consul/client.go @@ -88,7 +88,8 @@ type Client struct { tlsConfigurator *tlsutil.Configurator } -func NewClientWithOptions(config *Config, options ...ConsulOption) (*Client, error) { +// NewClient creates and returns a Client +func NewClient(config *Config, options ...ConsulOption) (*Client, error) { flat := flattenConsulOptions(options) tlsConfigurator := flat.tlsConfigurator diff --git a/agent/consul/leader_test.go b/agent/consul/leader_test.go index 9c632a5eab..ed34091197 100644 --- a/agent/consul/leader_test.go +++ b/agent/consul/leader_test.go @@ -1306,7 +1306,7 @@ func TestLeader_ConfigEntryBootstrap_Fail(t *testing.T) { }) tlsConf, err := tlsutil.NewConfigurator(config.ToTLSUtilConfig(), logger) require.NoError(t, err) - srv, err := NewServerWithOptions(config, + srv, err := NewServer(config, WithLogger(logger), WithTokenStore(new(token.Store)), WithTLSConfigurator(tlsConf)) diff --git a/agent/consul/server.go b/agent/consul/server.go index f878cf7692..5ba45d71ce 100644 --- a/agent/consul/server.go +++ b/agent/consul/server.go @@ -313,9 +313,9 @@ type Server struct { EnterpriseServer } -// NewServerWithOptions is used to construct a new Consul server from the configuration -// and extra options, potentially returning an error -func NewServerWithOptions(config *Config, options ...ConsulOption) (*Server, error) { +// NewServer is used to construct a new Consul server from the configuration +// and extra options, potentially returning an error. +func NewServer(config *Config, options ...ConsulOption) (*Server, error) { flat := flattenConsulOptions(options) logger := flat.logger