Browse Source

Rename NewClient/NewServer

Now that duplicate constructors have been removed we can use the shorter names for the single constructor.
pull/8404/head
Daniel Nephin 4 years ago
parent
commit
3b82ad0955
  1. 4
      agent/agent.go
  2. 3
      agent/consul/client.go
  3. 2
      agent/consul/leader_test.go
  4. 6
      agent/consul/server.go

4
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)
}

3
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

2
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))

6
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

Loading…
Cancel
Save