Rename NewClient/NewServer

Now that duplicate constructors have been removed we can use the shorter names for the single constructor.
This commit is contained in:
Daniel Nephin 2020-08-05 13:20:12 -04:00
parent 0420d91cdd
commit 3b82ad0955
4 changed files with 8 additions and 7 deletions

View File

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

View File

@ -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

View File

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

View File

@ -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