Skip to content

Commit e78a1bd

Browse files
committed
adds ConsulAPIWrapper
1 parent 16278d5 commit e78a1bd

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ example: tagit run -s my-super-service -x '/tmp/tag-role.sh'
7070
os.Exit(1)
7171
}
7272

73-
t := tagit.New(consulClient, &tagit.CmdExecutor{}, serviceID, script, validInterval, tagPrefix)
73+
t := tagit.New(tagit.NewConsulAPIWrapper(consulClient), &tagit.CmdExecutor{}, serviceID, script, validInterval, tagPrefix)
7474
t.Run()
7575
},
7676
}

pkg/tagit/tagit.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ type ConsulAgent interface {
3434
ServiceRegister(*api.AgentServiceRegistration) error
3535
}
3636

37+
// ConsulAPIWrapper wraps the Consul API client to conform to the ConsulClient interface.
38+
type ConsulAPIWrapper struct {
39+
client *api.Client
40+
}
41+
42+
// NewConsulAPIWrapper creates a new instance of ConsulAPIWrapper.
43+
func NewConsulAPIWrapper(client *api.Client) *ConsulAPIWrapper {
44+
return &ConsulAPIWrapper{client: client}
45+
}
46+
47+
// Agent returns an object that conforms to the ConsulAgent interface.
48+
func (w *ConsulAPIWrapper) Agent() ConsulAgent {
49+
return w.client.Agent()
50+
}
51+
3752
// CommandExecutor is an interface for running commands.
3853
type CommandExecutor interface {
3954
Execute(command string) ([]byte, error)

0 commit comments

Comments
 (0)