Rename `CertDir` to `Directory`
This commit is contained in:
parent
3dcb758f8e
commit
4f380559fe
|
|
@ -35,7 +35,7 @@ type APIServer struct {
|
|||
ProcessStarter SimpleSessionStarter
|
||||
|
||||
// CertDir is a struct holding a path to a certificate directory and a function to cleanup that directory.
|
||||
CertDir *CertDir
|
||||
CertDir *Directory
|
||||
|
||||
// Etcd is an implementation of a ControlPlaneProcess and is responsible to run Etcd and provide its coordinates.
|
||||
// If not specified, a brand new instance of Etcd is brought up.
|
||||
|
|
@ -147,7 +147,7 @@ func (s *APIServer) ensureInitialized() error {
|
|||
}
|
||||
}
|
||||
if s.CertDir == nil {
|
||||
certDir, err := newCertDir()
|
||||
certDir, err := newDirectory()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ var _ = Describe("Apiserver", func() {
|
|||
apiServer = &APIServer{
|
||||
AddressManager: fakeAddressManager,
|
||||
Path: "/some/path/to/apiserver",
|
||||
CertDir: &CertDir{
|
||||
CertDir: &Directory{
|
||||
Path: "/some/path/to/certdir",
|
||||
Cleanup: func() error {
|
||||
cleanupCallCount += 1
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
// CertDir holds a path to a directory and knows how to tear down / cleanup that directory
|
||||
type CertDir struct {
|
||||
Path string
|
||||
Cleanup func() error
|
||||
}
|
||||
|
||||
func newCertDir() (*CertDir, error) {
|
||||
path, err := ioutil.TempDir("", "cert_dir-")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &CertDir{
|
||||
Path: path,
|
||||
Cleanup: func() error {
|
||||
return os.RemoveAll(path)
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Directory holds a path to a directory and knows how to tear down / cleanup that directory
|
||||
type Directory struct {
|
||||
Path string
|
||||
Cleanup func() error
|
||||
}
|
||||
|
||||
func newDirectory() (*Directory, error) {
|
||||
path, err := ioutil.TempDir("", "k8s_test_framework_")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Directory{
|
||||
Path: path,
|
||||
Cleanup: func() error {
|
||||
return os.RemoveAll(path)
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
var _ = Describe("NewCertDir", func() {
|
||||
It("returns a valid CertDir struct", func() {
|
||||
certDir, err := newCertDir()
|
||||
certDir, err := newDirectory()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(certDir.Path).To(BeADirectory())
|
||||
Expect(certDir.Cleanup()).To(Succeed())
|
||||
Loading…
Reference in New Issue