diff --git a/drivers/azure/azure.go b/drivers/azure/azure.go index 30e5d216fd..13e8897e44 100644 --- a/drivers/azure/azure.go +++ b/drivers/azure/azure.go @@ -5,7 +5,7 @@ import ( "net" "os" "os/exec" - "path" + "path/filepath" "strings" "time" @@ -543,7 +543,7 @@ func (driver *Driver) generateCertForAzure() error { } func (driver *Driver) sshKeyPath() string { - return path.Join(driver.storePath, "id_rsa") + return filepath.Join(driver.storePath, "id_rsa") } func (driver *Driver) publicSSHKeyPath() string { @@ -551,5 +551,5 @@ func (driver *Driver) publicSSHKeyPath() string { } func (driver *Driver) azureCertPath() string { - return path.Join(driver.storePath, "azure_cert.pem") + return filepath.Join(driver.storePath, "azure_cert.pem") } diff --git a/drivers/digitalocean/digitalocean.go b/drivers/digitalocean/digitalocean.go index 60d9ea9a4b..7db4577420 100644 --- a/drivers/digitalocean/digitalocean.go +++ b/drivers/digitalocean/digitalocean.go @@ -5,7 +5,7 @@ import ( "io/ioutil" "os" "os/exec" - "path" + "path/filepath" "time" "code.google.com/p/goauth2/oauth" @@ -318,7 +318,7 @@ func (d *Driver) getClient() *godo.Client { } func (d *Driver) sshKeyPath() string { - return path.Join(d.storePath, "id_rsa") + return filepath.Join(d.storePath, "id_rsa") } func (d *Driver) publicSSHKeyPath() string { diff --git a/drivers/utils.go b/drivers/utils.go index aaa9d57be0..a15b75c6ef 100644 --- a/drivers/utils.go +++ b/drivers/utils.go @@ -15,7 +15,7 @@ func GetHomeDir() string { } func PublicKeyPath() string { - return filepath.Join(GetHomeDir(), ".docker/public-key.json") + return filepath.Join(GetHomeDir(), ".docker", "public-key.json") } func AddPublicKeyToAuthorizedHosts(d Driver, authorizedKeysPath string) error { diff --git a/drivers/virtualbox/virtualbox.go b/drivers/virtualbox/virtualbox.go index 70a88018cf..e4ab774d0f 100644 --- a/drivers/virtualbox/virtualbox.go +++ b/drivers/virtualbox/virtualbox.go @@ -11,7 +11,7 @@ import ( "net/http" "os" "os/exec" - "path" + "path/filepath" "regexp" "runtime" "strconv" @@ -221,7 +221,7 @@ func (d *Driver) Create() error { "--port", "0", "--device", "0", "--type", "dvddrive", - "--medium", path.Join(d.storePath, "boot2docker.iso")); err != nil { + "--medium", filepath.Join(d.storePath, "boot2docker.iso")); err != nil { return err } @@ -446,7 +446,7 @@ func (d *Driver) GetSSHCommand(args ...string) (*exec.Cmd, error) { } func (d *Driver) sshKeyPath() string { - return path.Join(d.storePath, "id_rsa") + return filepath.Join(d.storePath, "id_rsa") } func (d *Driver) publicSSHKeyPath() string { @@ -454,7 +454,7 @@ func (d *Driver) publicSSHKeyPath() string { } func (d *Driver) diskPath() string { - return path.Join(d.storePath, "disk.vmdk") + return filepath.Join(d.storePath, "disk.vmdk") } // Get the latest boot2docker release tag name (e.g. "v0.6.0"). @@ -502,7 +502,7 @@ func downloadISO(dir, file, url string) error { if err := f.Close(); err != nil { return err } - if err := os.Rename(f.Name(), path.Join(dir, file)); err != nil { + if err := os.Rename(f.Name(), filepath.Join(dir, file)); err != nil { return err } return nil diff --git a/host.go b/host.go index aa3476034b..8a8270dfaf 100644 --- a/host.go +++ b/host.go @@ -5,7 +5,7 @@ import ( "fmt" "io/ioutil" "os" - "path" + "path/filepath" "regexp" log "github.com/Sirupsen/logrus" @@ -105,7 +105,7 @@ func (h *Host) GetURL() (string, error) { } func (h *Host) LoadConfig() error { - data, err := ioutil.ReadFile(path.Join(h.storePath, "config.json")) + data, err := ioutil.ReadFile(filepath.Join(h.storePath, "config.json")) if err != nil { return err } @@ -135,7 +135,7 @@ func (h *Host) SaveConfig() error { if err != nil { return err } - if err := ioutil.WriteFile(path.Join(h.storePath, "config.json"), data, 0600); err != nil { + if err := ioutil.WriteFile(filepath.Join(h.storePath, "config.json"), data, 0600); err != nil { return err } return nil diff --git a/store.go b/store.go index 10977866a5..c3951c5ec3 100644 --- a/store.go +++ b/store.go @@ -4,7 +4,7 @@ import ( "fmt" "io/ioutil" "os" - "path" + "path/filepath" log "github.com/Sirupsen/logrus" "github.com/docker/machine/drivers" @@ -16,7 +16,7 @@ type Store struct { } func NewStore() *Store { - rootPath := path.Join(drivers.GetHomeDir(), ".docker/hosts") + rootPath := filepath.Join(drivers.GetHomeDir(), ".docker", "hosts") return &Store{Path: rootPath} } @@ -29,7 +29,7 @@ func (s *Store) Create(name string, driverName string, flags drivers.DriverOptio return nil, fmt.Errorf("Host %q already exists", name) } - hostPath := path.Join(s.Path, name) + hostPath := filepath.Join(s.Path, name) host, err := NewHost(name, driverName, hostPath) if err != nil { @@ -95,7 +95,7 @@ func (s *Store) List() ([]Host, error) { } func (s *Store) Exists(name string) (bool, error) { - _, err := os.Stat(path.Join(s.Path, name)) + _, err := os.Stat(filepath.Join(s.Path, name)) if os.IsNotExist(err) { return false, nil } else if err == nil { @@ -105,7 +105,7 @@ func (s *Store) Exists(name string) (bool, error) { } func (s *Store) Load(name string) (*Host, error) { - hostPath := path.Join(s.Path, name) + hostPath := filepath.Join(s.Path, name) return LoadHost(name, hostPath) } @@ -131,7 +131,7 @@ func (s *Store) IsActive(host *Host) (bool, error) { } func (s *Store) SetActive(host *Host) error { - if err := os.MkdirAll(path.Dir(s.activePath()), 0700); err != nil { + if err := os.MkdirAll(filepath.Dir(s.activePath()), 0700); err != nil { return err } return ioutil.WriteFile(s.activePath(), []byte(host.Name), 0600) @@ -144,5 +144,5 @@ func (s *Store) RemoveActive() error { // activePath returns the path to the file that stores the name of the // active host func (s *Store) activePath() string { - return path.Join(s.Path, ".active") + return filepath.Join(s.Path, ".active") } diff --git a/store_test.go b/store_test.go index 9149c37fcf..ddd2114dd2 100644 --- a/store_test.go +++ b/store_test.go @@ -3,6 +3,7 @@ package main import ( "os" "path" + "path/filepath" "testing" "github.com/docker/machine/drivers" @@ -26,7 +27,7 @@ func (d DriverOptionsMock) Bool(key string) bool { } func clearHosts() error { - return os.RemoveAll(path.Join(drivers.GetHomeDir(), ".docker/hosts")) + return os.RemoveAll(path.Join(drivers.GetHomeDir(), ".docker", "hosts")) } func TestStoreCreate(t *testing.T) { @@ -49,7 +50,7 @@ func TestStoreCreate(t *testing.T) { if host.Name != "test" { t.Fatal("Host name is incorrect") } - path := path.Join(drivers.GetHomeDir(), ".docker/hosts/test") + path := filepath.Join(drivers.GetHomeDir(), ".docker", "hosts", "test") if _, err := os.Stat(path); os.IsNotExist(err) { t.Fatalf("Host path doesn't exist: %s", path) } @@ -71,7 +72,7 @@ func TestStoreRemove(t *testing.T) { if err != nil { t.Fatal(err) } - path := path.Join(drivers.GetHomeDir(), ".docker/hosts/test") + path := filepath.Join(drivers.GetHomeDir(), ".docker", "hosts", "test") if _, err := os.Stat(path); os.IsNotExist(err) { t.Fatalf("Host path doesn't exist: %s", path) }