Skip to content

Commit f2a36e3

Browse files
committed
remove consul from interface names
1 parent 86f826e commit f2a36e3

File tree

5 files changed

+36
-37
lines changed

5 files changed

+36
-37
lines changed

cmd/cleanup_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ func TestCleanupCmdSuccessFlow(t *testing.T) {
305305

306306
// MockConsulClient for testing
307307
type MockConsulClient struct {
308-
MockAgent consul.ConsulAgent
308+
MockAgent consul.Agent
309309
}
310310

311-
func (m *MockConsulClient) Agent() consul.ConsulAgent {
311+
func (m *MockConsulClient) Agent() consul.Agent {
312312
return m.MockAgent
313313
}
314314

315-
// MockAgent implements the ConsulAgent interface
315+
// MockAgent implements the Agent interface
316316
type MockAgent struct {
317317
ServiceFunc func(serviceID string, q *api.QueryOptions) (*api.AgentService, *api.QueryMeta, error)
318318
ServiceRegisterFunc func(reg *api.AgentServiceRegistration) error

pkg/consul/factory.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,42 @@ import (
2121
"github.com/hashicorp/consul/api"
2222
)
2323

24-
// ConsulClient is an interface for the Consul client.
25-
type ConsulClient interface {
26-
Agent() ConsulAgent
24+
// Client is an interface for the Consul client.
25+
type Client interface {
26+
Agent() Agent
2727
}
2828

29-
// ConsulAgent is an interface for the Consul agent.
30-
type ConsulAgent interface {
29+
// Agent is an interface for the Consul agent.
30+
type Agent interface {
3131
Service(string, *api.QueryOptions) (*api.AgentService, *api.QueryMeta, error)
3232
ServiceRegister(*api.AgentServiceRegistration) error
3333
}
3434

35-
// ConsulAPIWrapper wraps the Consul API client to conform to the ConsulClient interface.
36-
type ConsulAPIWrapper struct {
35+
// ApiWrapper wraps the Consul API client to conform to the Client interface.
36+
type ApiWrapper struct {
3737
client *api.Client
3838
}
3939

40-
// NewConsulAPIWrapper creates a new instance of ConsulAPIWrapper.
41-
func NewConsulAPIWrapper(client *api.Client) *ConsulAPIWrapper {
42-
return &ConsulAPIWrapper{client: client}
40+
// NewConsulAPIWrapper creates a new instance of ApiWrapper.
41+
func NewConsulAPIWrapper(client *api.Client) *ApiWrapper {
42+
return &ApiWrapper{client: client}
4343
}
4444

45-
// Agent returns an object that conforms to the ConsulAgent interface.
46-
func (w *ConsulAPIWrapper) Agent() ConsulAgent {
45+
// Agent returns an object that conforms to the Agent interface.
46+
func (w *ApiWrapper) Agent() Agent {
4747
return w.client.Agent()
4848
}
4949

5050
// ClientFactory is an interface for creating Consul clients
5151
type ClientFactory interface {
52-
NewClient(address, token string) (ConsulClient, error)
52+
NewClient(address, token string) (Client, error)
5353
}
5454

5555
// DefaultFactory creates real Consul clients
5656
type DefaultFactory struct{}
5757

5858
// NewClient creates a new Consul client with the given configuration
59-
func (f *DefaultFactory) NewClient(address, token string) (ConsulClient, error) {
59+
func (f *DefaultFactory) NewClient(address, token string) (Client, error) {
6060
config := api.DefaultConfig()
6161
config.Address = address
6262
config.Token = token
@@ -71,12 +71,12 @@ func (f *DefaultFactory) NewClient(address, token string) (ConsulClient, error)
7171

7272
// MockFactory creates mock Consul clients for testing
7373
type MockFactory struct {
74-
MockClient ConsulClient
74+
MockClient Client
7575
MockError error
7676
}
7777

7878
// NewClient returns the mock client or error
79-
func (f *MockFactory) NewClient(address, token string) (ConsulClient, error) {
79+
func (f *MockFactory) NewClient(address, token string) (Client, error) {
8080
if f.MockError != nil {
8181
return nil, f.MockError
8282
}
@@ -97,6 +97,6 @@ func ResetFactory() {
9797
}
9898

9999
// CreateClient is a convenience function that uses the global factory
100-
func CreateClient(address, token string) (ConsulClient, error) {
100+
func CreateClient(address, token string) (Client, error) {
101101
return Factory.NewClient(address, token)
102-
}
102+
}

pkg/consul/factory_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type MockConsulClient struct {
1313
MockAgent *MockAgent
1414
}
1515

16-
func (m *MockConsulClient) Agent() ConsulAgent {
16+
func (m *MockConsulClient) Agent() Agent {
1717
return m.MockAgent
1818
}
1919

@@ -120,4 +120,4 @@ func TestGlobalFactory(t *testing.T) {
120120
_, ok := Factory.(*DefaultFactory)
121121
assert.True(t, ok, "Factory should be reset to DefaultFactory")
122122
})
123-
}
123+
}

pkg/tagit/tagit.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ type TagIt struct {
2020
Script string
2121
Interval time.Duration
2222
TagPrefix string
23-
client consul.ConsulClient
23+
client consul.Client
2424
commandExecutor CommandExecutor
2525
logger *slog.Logger
2626
}
2727

28-
2928
// CommandExecutor is an interface for running commands.
3029
type CommandExecutor interface {
3130
Execute(command string) ([]byte, error)
@@ -48,7 +47,7 @@ func (e *CmdExecutor) Execute(command string) ([]byte, error) {
4847
}
4948

5049
// New creates a new TagIt struct.
51-
func New(consulClient consul.ConsulClient, commandExecutor CommandExecutor, serviceID string, script string, interval time.Duration, tagPrefix string, logger *slog.Logger) *TagIt {
50+
func New(consulClient consul.Client, commandExecutor CommandExecutor, serviceID string, script string, interval time.Duration, tagPrefix string, logger *slog.Logger) *TagIt {
5251
return &TagIt{
5352
ServiceID: serviceID,
5453
Script: script,

pkg/tagit/tagit_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import (
1515
"github.com/stretchr/testify/assert"
1616
)
1717

18-
// MockConsulClient implements the ConsulClient interface for testing.
18+
// MockConsulClient implements the Client interface for testing.
1919
type MockConsulClient struct {
2020
MockAgent *MockAgent
2121
}
2222

23-
func (m *MockConsulClient) Agent() consul.ConsulAgent {
23+
func (m *MockConsulClient) Agent() consul.Agent {
2424
return m.MockAgent
2525
}
2626

@@ -607,21 +607,21 @@ func TestConsulInterfaceCompatibility(t *testing.T) {
607607
return nil
608608
},
609609
}
610-
610+
611611
mockClient := &MockConsulClient{
612612
MockAgent: mockAgent,
613613
}
614-
615-
// Verify that MockConsulClient implements consul.ConsulClient
616-
var _ consul.ConsulClient = mockClient
617-
618-
// Verify that MockAgent implements consul.ConsulAgent
619-
var _ consul.ConsulAgent = mockAgent
620-
614+
615+
// Verify that MockConsulClient implements consul.Client
616+
var _ consul.Client = mockClient
617+
618+
// Verify that MockAgent implements consul.Agent
619+
var _ consul.Agent = mockAgent
620+
621621
// Test that the mock client works correctly
622622
agent := mockClient.Agent()
623623
assert.NotNil(t, agent, "Agent() should return non-nil")
624-
624+
625625
service, _, err := agent.Service("test-service", nil)
626626
assert.NoError(t, err)
627627
assert.Equal(t, "test-service", service.ID)

0 commit comments

Comments
 (0)