Add APIServer constructor with default binary path
This commit is contained in:
parent
3bdc1f4b9b
commit
e6b042840b
|
|
@ -31,8 +31,24 @@ type certDirManager interface {
|
||||||
|
|
||||||
//go:generate counterfeiter . certDirManager
|
//go:generate counterfeiter . certDirManager
|
||||||
|
|
||||||
// NewAPIServer creates a new APIServer Fixture Process
|
var apiServerBinPathFinder = DefaultBinPathFinder
|
||||||
func NewAPIServer(pathToAPIServer string, config *APIServerConfig) *APIServer {
|
|
||||||
|
// NewAPIServer constructs a new APIServer with whatever api_server binary it can find.
|
||||||
|
func NewAPIServer(config *APIServerConfig) *APIServer {
|
||||||
|
starter := func(command *exec.Cmd, out, err io.Writer) (SimpleSession, error) {
|
||||||
|
return gexec.Start(command, out, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &APIServer{
|
||||||
|
Path: apiServerBinPathFinder("kube_apiserver"),
|
||||||
|
Config: config,
|
||||||
|
ProcessStarter: starter,
|
||||||
|
CertDirManager: &TempDirManager{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAPIServerWithBinary creates a new APIServer Fixture Process
|
||||||
|
func NewAPIServerWithBinary(pathToAPIServer string, config *APIServerConfig) *APIServer {
|
||||||
starter := func(command *exec.Cmd, out, err io.Writer) (SimpleSession, error) {
|
starter := func(command *exec.Cmd, out, err io.Writer) (SimpleSession, error) {
|
||||||
return gexec.Start(command, out, err)
|
return gexec.Start(command, out, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package test
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("NewAPIServer", func() {
|
||||||
|
var oldAPIServerBinPathFinder BinPathFinder
|
||||||
|
BeforeEach(func() {
|
||||||
|
oldAPIServerBinPathFinder = apiServerBinPathFinder
|
||||||
|
})
|
||||||
|
AfterEach(func() {
|
||||||
|
apiServerBinPathFinder = oldAPIServerBinPathFinder
|
||||||
|
})
|
||||||
|
|
||||||
|
It("can construct a properly configured APIServer", func() {
|
||||||
|
config := &APIServerConfig{
|
||||||
|
EtcdURL: "some etcd URL",
|
||||||
|
APIServerURL: "some APIServer URL",
|
||||||
|
}
|
||||||
|
apiServerBinPathFinder = func(name string) string {
|
||||||
|
Expect(name).To(Equal("kube_apiserver"))
|
||||||
|
return "some api server path"
|
||||||
|
}
|
||||||
|
|
||||||
|
apiServer := NewAPIServer(config)
|
||||||
|
|
||||||
|
Expect(apiServer).NotTo(BeNil())
|
||||||
|
Expect(apiServer.ProcessStarter).NotTo(BeNil())
|
||||||
|
Expect(apiServer.CertDirManager).NotTo(BeNil())
|
||||||
|
Expect(apiServer.Path).To(Equal("some api server path"))
|
||||||
|
Expect(apiServer.Config).To(Equal(config))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
@ -48,7 +48,7 @@ func NewFixtures(pathToEtcd, pathToAPIServer string) (*Fixtures, error) {
|
||||||
|
|
||||||
fixtures := &Fixtures{
|
fixtures := &Fixtures{
|
||||||
Etcd: NewEtcdWithBinaryAndConfig(pathToEtcd, etcdConfig),
|
Etcd: NewEtcdWithBinaryAndConfig(pathToEtcd, etcdConfig),
|
||||||
APIServer: NewAPIServer(pathToAPIServer, apiServerConfig),
|
APIServer: NewAPIServerWithBinary(pathToAPIServer, apiServerConfig),
|
||||||
}
|
}
|
||||||
|
|
||||||
fixtures.Config = FixturesConfig{
|
fixtures.Config = FixturesConfig{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue