From 4f380559fe9daa9b1ff08608afecf99baf1081ba Mon Sep 17 00:00:00 2001 From: Gareth Smith Date: Fri, 5 Jan 2018 10:30:01 +0000 Subject: [PATCH] Rename `CertDir` to `Directory` --- pkg/framework/test/apiserver.go | 4 +-- pkg/framework/test/apiserver_test.go | 2 +- pkg/framework/test/cert_dir.go | 26 ------------------- pkg/framework/test/directory.go | 26 +++++++++++++++++++ .../{cert_dir_test.go => directory_test.go} | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 pkg/framework/test/cert_dir.go create mode 100644 pkg/framework/test/directory.go rename pkg/framework/test/{cert_dir_test.go => directory_test.go} (91%) diff --git a/pkg/framework/test/apiserver.go b/pkg/framework/test/apiserver.go index 5adeba917..16d919f01 100644 --- a/pkg/framework/test/apiserver.go +++ b/pkg/framework/test/apiserver.go @@ -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 } diff --git a/pkg/framework/test/apiserver_test.go b/pkg/framework/test/apiserver_test.go index ce670d809..c9a660faf 100644 --- a/pkg/framework/test/apiserver_test.go +++ b/pkg/framework/test/apiserver_test.go @@ -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 diff --git a/pkg/framework/test/cert_dir.go b/pkg/framework/test/cert_dir.go deleted file mode 100644 index c7e29b56a..000000000 --- a/pkg/framework/test/cert_dir.go +++ /dev/null @@ -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 -} diff --git a/pkg/framework/test/directory.go b/pkg/framework/test/directory.go new file mode 100644 index 000000000..f4a92d89a --- /dev/null +++ b/pkg/framework/test/directory.go @@ -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 +} diff --git a/pkg/framework/test/cert_dir_test.go b/pkg/framework/test/directory_test.go similarity index 91% rename from pkg/framework/test/cert_dir_test.go rename to pkg/framework/test/directory_test.go index 90b518c64..65342b05e 100644 --- a/pkg/framework/test/cert_dir_test.go +++ b/pkg/framework/test/directory_test.go @@ -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())