Rename CommonStuff to ProcessState

This commit is contained in:
Hannes Hörl 2018-01-12 11:45:37 +00:00
parent 4022e2b56f
commit 9990f29acd
4 changed files with 37 additions and 37 deletions

View File

@ -41,7 +41,7 @@ type APIServer struct {
session *gexec.Session
commonStuff internal.CommonStuff
processState internal.ProcessState
}
// Start starts the apiserver, waits for it to come up, and returns an error, if occoured.
@ -58,7 +58,7 @@ func (s *APIServer) Start() error {
return err
}
etcdURLString := s.Etcd.commonStuff.URL.String()
etcdURLString := s.Etcd.processState.URL.String()
args := []string{
"--authorization-mode=Node,RBAC",
@ -69,15 +69,15 @@ func (s *APIServer) Start() error {
"--bind-address=0.0.0.0",
"--storage-backend=etcd3",
fmt.Sprintf("--etcd-servers=%s", etcdURLString),
fmt.Sprintf("--cert-dir=%s", s.commonStuff.Dir),
fmt.Sprintf("--insecure-port=%s", s.commonStuff.URL.Port()),
fmt.Sprintf("--insecure-bind-address=%s", s.commonStuff.URL.Hostname()),
fmt.Sprintf("--cert-dir=%s", s.processState.Dir),
fmt.Sprintf("--insecure-port=%s", s.processState.URL.Port()),
fmt.Sprintf("--insecure-bind-address=%s", s.processState.URL.Hostname()),
}
s.session, err = internal.Start(
exec.Command(s.commonStuff.Path, args...),
fmt.Sprintf("Serving insecurely on %s", s.commonStuff.URL.Host),
s.commonStuff.StartTimeout,
exec.Command(s.processState.Path, args...),
fmt.Sprintf("Serving insecurely on %s", s.processState.URL.Host),
s.processState.StartTimeout,
)
return err
@ -86,7 +86,7 @@ func (s *APIServer) Start() error {
func (s *APIServer) ensureInitialized() error {
var err error
s.commonStuff, err = internal.NewCommonStuff(
s.processState, err = internal.NewProcessState(
"kube-apiserver",
s.Path,
s.URL,
@ -108,9 +108,9 @@ func (s *APIServer) ensureInitialized() error {
func (s *APIServer) Stop() error {
err := internal.Stop(
s.session,
s.commonStuff.StopTimeout,
s.commonStuff.Dir,
s.commonStuff.DirNeedsCleaning,
s.processState.StopTimeout,
s.processState.Dir,
s.processState.DirNeedsCleaning,
)
if err != nil {
return err

View File

@ -31,5 +31,5 @@ func (f *ControlPlane) Stop() error {
// APIURL returns the URL you should connect to to talk to your API.
func (f *ControlPlane) APIURL() *url.URL {
return f.APIServer.commonStuff.URL
return f.APIServer.processState.URL
}

View File

@ -23,7 +23,7 @@ type Etcd struct {
StartTimeout time.Duration
session *gexec.Session
commonStuff internal.CommonStuff
processState internal.ProcessState
}
// Start starts the etcd, waits for it to come up, and returns an error, if occoured.
@ -36,15 +36,15 @@ func (e *Etcd) Start() error {
args := []string{
"--debug",
"--listen-peer-urls=http://localhost:0",
fmt.Sprintf("--advertise-client-urls=%s", e.commonStuff.URL),
fmt.Sprintf("--listen-client-urls=%s", e.commonStuff.URL),
fmt.Sprintf("--data-dir=%s", e.commonStuff.Dir),
fmt.Sprintf("--advertise-client-urls=%s", e.processState.URL),
fmt.Sprintf("--listen-client-urls=%s", e.processState.URL),
fmt.Sprintf("--data-dir=%s", e.processState.Dir),
}
e.session, err = internal.Start(
exec.Command(e.commonStuff.Path, args...),
fmt.Sprintf("serving insecure client requests on %s", e.commonStuff.URL.Hostname()),
e.commonStuff.StartTimeout,
exec.Command(e.processState.Path, args...),
fmt.Sprintf("serving insecure client requests on %s", e.processState.URL.Hostname()),
e.processState.StartTimeout,
)
return err
@ -52,7 +52,7 @@ func (e *Etcd) Start() error {
func (e *Etcd) ensureInitialized() error {
var err error
e.commonStuff, err = internal.NewCommonStuff(
e.processState, err = internal.NewProcessState(
"etcd",
e.Path,
e.URL,
@ -66,8 +66,8 @@ func (e *Etcd) ensureInitialized() error {
func (e *Etcd) Stop() error {
return internal.Stop(
e.session,
e.commonStuff.StopTimeout,
e.commonStuff.Dir,
e.commonStuff.DirNeedsCleaning,
e.processState.StopTimeout,
e.processState.Dir,
e.processState.DirNeedsCleaning,
)
}

View File

@ -14,7 +14,7 @@ import (
"github.com/onsi/gomega/gexec"
)
type CommonStuff struct {
type ProcessState struct {
URL *url.URL
Dir string
DirNeedsCleaning bool
@ -64,15 +64,15 @@ func Stop(session *gexec.Session, stopTimeout time.Duration, dirToClean string,
return nil
}
func NewCommonStuff(
func NewProcessState(
symbolicName string,
path string,
listenURL *url.URL,
dir string,
startTimeout time.Duration,
stopTimeout time.Duration,
) (CommonStuff, error) {
common := CommonStuff{
) (ProcessState, error) {
state := ProcessState{
Path: path,
URL: listenURL,
Dir: dir,
@ -82,16 +82,16 @@ func NewCommonStuff(
}
if path == "" {
common.Path = BinPathFinder(symbolicName)
state.Path = BinPathFinder(symbolicName)
}
if listenURL == nil {
am := &AddressManager{}
port, host, err := am.Initialize()
if err != nil {
return CommonStuff{}, err
return ProcessState{}, err
}
common.URL = &url.URL{
state.URL = &url.URL{
Scheme: "http",
Host: fmt.Sprintf("%s:%d", host, port),
}
@ -100,19 +100,19 @@ func NewCommonStuff(
if dir == "" {
newDir, err := ioutil.TempDir("", "k8s_test_framework_")
if err != nil {
return CommonStuff{}, err
return ProcessState{}, err
}
common.Dir = newDir
common.DirNeedsCleaning = true
state.Dir = newDir
state.DirNeedsCleaning = true
}
if stopTimeout == 0 {
common.StopTimeout = 20 * time.Second
state.StopTimeout = 20 * time.Second
}
if startTimeout == 0 {
common.StartTimeout = 20 * time.Second
state.StartTimeout = 20 * time.Second
}
return common, nil
return state, nil
}