Replace Etcd.PathFinder with Etcd.Path
This commit is contained in:
parent
2b25091098
commit
3f26c08fd0
|
|
@ -16,7 +16,7 @@ import (
|
||||||
// in the documentation for the `APIServer`, as both implement a `ControlPaneProcess`.
|
// in the documentation for the `APIServer`, as both implement a `ControlPaneProcess`.
|
||||||
type Etcd struct {
|
type Etcd struct {
|
||||||
AddressManager AddressManager
|
AddressManager AddressManager
|
||||||
PathFinder BinPathFinder
|
Path string
|
||||||
ProcessStarter SimpleSessionStarter
|
ProcessStarter SimpleSessionStarter
|
||||||
DataDirManager DataDirManager
|
DataDirManager DataDirManager
|
||||||
StopTimeout time.Duration
|
StopTimeout time.Duration
|
||||||
|
|
@ -92,7 +92,7 @@ func (e *Etcd) Start() error {
|
||||||
"serving insecure client requests on %s", host))
|
"serving insecure client requests on %s", host))
|
||||||
timedOut := time.After(e.StartTimeout)
|
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)
|
e.session, err = e.ProcessStarter(command, e.stdOut, e.stdErr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -107,8 +107,8 @@ func (e *Etcd) Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Etcd) ensureInitialized() {
|
func (e *Etcd) ensureInitialized() {
|
||||||
if e.PathFinder == nil {
|
if e.Path == "" {
|
||||||
e.PathFinder = DefaultBinPathFinder
|
e.Path = DefaultBinPathFinder("etcd")
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.AddressManager == nil {
|
if e.AddressManager == nil {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ var _ = Describe("Etcd", func() {
|
||||||
var (
|
var (
|
||||||
fakeSession *testfakes.FakeSimpleSession
|
fakeSession *testfakes.FakeSimpleSession
|
||||||
fakeDataDirManager *testfakes.FakeDataDirManager
|
fakeDataDirManager *testfakes.FakeDataDirManager
|
||||||
fakePathFinder *testfakes.FakeBinPathFinder
|
|
||||||
fakeAddressManager *testfakes.FakeAddressManager
|
fakeAddressManager *testfakes.FakeAddressManager
|
||||||
etcd *Etcd
|
etcd *Etcd
|
||||||
etcdStopper chan struct{}
|
etcdStopper chan struct{}
|
||||||
|
|
@ -28,7 +27,6 @@ var _ = Describe("Etcd", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
fakeSession = &testfakes.FakeSimpleSession{}
|
fakeSession = &testfakes.FakeSimpleSession{}
|
||||||
fakeDataDirManager = &testfakes.FakeDataDirManager{}
|
fakeDataDirManager = &testfakes.FakeDataDirManager{}
|
||||||
fakePathFinder = &testfakes.FakeBinPathFinder{}
|
|
||||||
fakeAddressManager = &testfakes.FakeAddressManager{}
|
fakeAddressManager = &testfakes.FakeAddressManager{}
|
||||||
|
|
||||||
etcdStopper = make(chan struct{}, 1)
|
etcdStopper = make(chan struct{}, 1)
|
||||||
|
|
@ -39,7 +37,7 @@ var _ = Describe("Etcd", func() {
|
||||||
|
|
||||||
etcd = &Etcd{
|
etcd = &Etcd{
|
||||||
AddressManager: fakeAddressManager,
|
AddressManager: fakeAddressManager,
|
||||||
PathFinder: fakePathFinder.Spy,
|
Path: "/path/to/some/etcd",
|
||||||
DataDirManager: fakeDataDirManager,
|
DataDirManager: fakeDataDirManager,
|
||||||
StopTimeout: 500 * time.Millisecond,
|
StopTimeout: 500 * time.Millisecond,
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +53,6 @@ var _ = Describe("Etcd", func() {
|
||||||
fakeSession.ExitCodeReturnsOnCall(0, -1)
|
fakeSession.ExitCodeReturnsOnCall(0, -1)
|
||||||
fakeSession.ExitCodeReturnsOnCall(1, 143)
|
fakeSession.ExitCodeReturnsOnCall(1, 143)
|
||||||
|
|
||||||
fakePathFinder.ReturnsOnCall(0, "/path/to/some/etcd")
|
|
||||||
fakeAddressManager.InitializeReturns(1234, "this.is.etcd.listening.for.clients", nil)
|
fakeAddressManager.InitializeReturns(1234, "this.is.etcd.listening.for.clients", nil)
|
||||||
|
|
||||||
etcd.ProcessStarter = func(command *exec.Cmd, out, err io.Writer) (SimpleSession, error) {
|
etcd.ProcessStarter = func(command *exec.Cmd, out, err io.Writer) (SimpleSession, error) {
|
||||||
|
|
@ -70,10 +67,6 @@ var _ = Describe("Etcd", func() {
|
||||||
err := etcd.Start()
|
err := etcd.Start()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
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")
|
By("...in turn calling using the AddressManager")
|
||||||
Expect(fakeAddressManager.InitializeCallCount()).To(Equal(1))
|
Expect(fakeAddressManager.InitializeCallCount()).To(Equal(1))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue