Replace Etcd.PathFinder with Etcd.Path

This commit is contained in:
Gareth Smith 2017-12-18 14:41:49 +00:00
parent 2b25091098
commit 3f26c08fd0
2 changed files with 5 additions and 12 deletions

View File

@ -16,7 +16,7 @@ import (
// in the documentation for the `APIServer`, as both implement a `ControlPaneProcess`.
type Etcd struct {
AddressManager AddressManager
PathFinder BinPathFinder
Path string
ProcessStarter SimpleSessionStarter
DataDirManager DataDirManager
StopTimeout time.Duration
@ -92,7 +92,7 @@ func (e *Etcd) Start() error {
"serving insecure client requests on %s", host))
timedOut := time.After(e.StartTimeout)
command := exec.Command(e.PathFinder("etcd"), args...)
command := exec.Command(e.Path, args...)
e.session, err = e.ProcessStarter(command, e.stdOut, e.stdErr)
if err != nil {
return err
@ -107,8 +107,8 @@ func (e *Etcd) Start() error {
}
func (e *Etcd) ensureInitialized() {
if e.PathFinder == nil {
e.PathFinder = DefaultBinPathFinder
if e.Path == "" {
e.Path = DefaultBinPathFinder("etcd")
}
if e.AddressManager == nil {

View File

@ -19,7 +19,6 @@ var _ = Describe("Etcd", func() {
var (
fakeSession *testfakes.FakeSimpleSession
fakeDataDirManager *testfakes.FakeDataDirManager
fakePathFinder *testfakes.FakeBinPathFinder
fakeAddressManager *testfakes.FakeAddressManager
etcd *Etcd
etcdStopper chan struct{}
@ -28,7 +27,6 @@ var _ = Describe("Etcd", func() {
BeforeEach(func() {
fakeSession = &testfakes.FakeSimpleSession{}
fakeDataDirManager = &testfakes.FakeDataDirManager{}
fakePathFinder = &testfakes.FakeBinPathFinder{}
fakeAddressManager = &testfakes.FakeAddressManager{}
etcdStopper = make(chan struct{}, 1)
@ -39,7 +37,7 @@ var _ = Describe("Etcd", func() {
etcd = &Etcd{
AddressManager: fakeAddressManager,
PathFinder: fakePathFinder.Spy,
Path: "/path/to/some/etcd",
DataDirManager: fakeDataDirManager,
StopTimeout: 500 * time.Millisecond,
}
@ -55,7 +53,6 @@ var _ = Describe("Etcd", func() {
fakeSession.ExitCodeReturnsOnCall(0, -1)
fakeSession.ExitCodeReturnsOnCall(1, 143)
fakePathFinder.ReturnsOnCall(0, "/path/to/some/etcd")
fakeAddressManager.InitializeReturns(1234, "this.is.etcd.listening.for.clients", nil)
etcd.ProcessStarter = func(command *exec.Cmd, out, err io.Writer) (SimpleSession, error) {
@ -70,10 +67,6 @@ var _ = Describe("Etcd", func() {
err := etcd.Start()
Expect(err).NotTo(HaveOccurred())
By("...in turn calling the PathFinder")
Expect(fakePathFinder.CallCount()).To(Equal(1))
Expect(fakePathFinder.ArgsForCall(0)).To(Equal("etcd"))
By("...in turn calling using the AddressManager")
Expect(fakeAddressManager.InitializeCallCount()).To(Equal(1))