From 8bbfc6ef2acf2e3d06a2f2728890eb26b066fddc Mon Sep 17 00:00:00 2001 From: David Gageot Date: Thu, 12 Nov 2015 17:23:52 +0100 Subject: [PATCH] Remove unused code Signed-off-by: David Gageot --- commands/commands.go | 12 ------- commands/commands_test.go | 3 +- libmachine/hosttest/default_test_host.go | 1 - libmachine/mcnerror/errors.go | 3 +- libmachine/persisttest/default_test_store.go | 34 -------------------- 5 files changed, 2 insertions(+), 51 deletions(-) delete mode 100644 libmachine/persisttest/default_test_store.go diff --git a/commands/commands.go b/commands/commands.go index b512585a1f..0eb4ae09b1 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -156,20 +156,8 @@ func getFirstArgHost(c CommandLine) (*host.Host, error) { store := getStore(c) hostName := c.Args().First() - exists, err := store.Exists(hostName) - if err != nil { - return nil, fmt.Errorf("Error checking if host %q exists: %s", hostName, err) - } - if !exists { - return nil, fmt.Errorf("Host %q does not exist", hostName) - } - h, err := loadHost(store, hostName) if err != nil { - // I guess I feel OK with bailing here since if we can't get - // the host reliably we're definitely not going to be able to - // do anything else interesting, but also this premature exit - // feels wrong to me. Let's revisit it later. return nil, fmt.Errorf("Error trying to get host %q: %s", hostName, err) } diff --git a/commands/commands_test.go b/commands/commands_test.go index 93d451c84d..517cbc2dff 100644 --- a/commands/commands_test.go +++ b/commands/commands_test.go @@ -8,7 +8,6 @@ import ( "github.com/docker/machine/drivers/fakedriver" "github.com/docker/machine/libmachine/host" "github.com/docker/machine/libmachine/hosttest" - "github.com/docker/machine/libmachine/persisttest" "github.com/docker/machine/libmachine/state" "github.com/stretchr/testify/assert" ) @@ -104,7 +103,7 @@ func TestRunActionForeachMachine(t *testing.T) { } func TestPrintIPEmptyGivenLocalEngine(t *testing.T) { - defer persisttest.Cleanup() + defer cleanup() host, _ := hosttest.GetDefaultTestHost() out, w := captureStdout() diff --git a/libmachine/hosttest/default_test_host.go b/libmachine/hosttest/default_test_host.go index 32f2403109..143a1201cf 100644 --- a/libmachine/hosttest/default_test_host.go +++ b/libmachine/hosttest/default_test_host.go @@ -11,7 +11,6 @@ import ( const ( DefaultHostName = "test-host" - HostTestDriverName = "none" HostTestCaCert = "test-cert" HostTestPrivateKey = "test-key" ) diff --git a/libmachine/mcnerror/errors.go b/libmachine/mcnerror/errors.go index 705276552d..61d8d2a4d1 100644 --- a/libmachine/mcnerror/errors.go +++ b/libmachine/mcnerror/errors.go @@ -6,8 +6,7 @@ import ( ) var ( - ErrInvalidHostname = errors.New("Invalid hostname specified. Allowed hostname chars are: 0-9a-zA-Z . -") - ErrUnknownProviderType = errors.New("Unknown hypervisor type") + ErrInvalidHostname = errors.New("Invalid hostname specified. Allowed hostname chars are: 0-9a-zA-Z . -") ) type ErrHostDoesNotExist struct { diff --git a/libmachine/persisttest/default_test_store.go b/libmachine/persisttest/default_test_store.go deleted file mode 100644 index 96b1dbe27d..0000000000 --- a/libmachine/persisttest/default_test_store.go +++ /dev/null @@ -1,34 +0,0 @@ -package persisttest - -import ( - "fmt" - "io/ioutil" - "os" - - "github.com/docker/machine/libmachine/hosttest" - "github.com/docker/machine/libmachine/persist" -) - -var ( - TestStoreDir = "" -) - -func Cleanup() error { - return os.RemoveAll(TestStoreDir) -} - -func GetDefaultTestStore() (persist.Filestore, error) { - tmpDir, err := ioutil.TempDir("", "machine-test-") - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - TestStoreDir = tmpDir - - return persist.Filestore{ - Path: tmpDir, - CaCertPath: hosttest.HostTestCaCert, - CaPrivateKeyPath: hosttest.HostTestPrivateKey, - }, nil -}