mirror of https://github.com/docker/docs.git
Moving path to filepath dependency
Signed-off-by: Damien DUPORTAL <damien.duportal@gmail.com> Conflicts: drivers/azure/azure.go store.go store_test.go
This commit is contained in:
parent
5f54122dc6
commit
eda8bbd2bd
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
6
host.go
6
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
|
||||
|
|
14
store.go
14
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")
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue