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"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ func (driver *Driver) generateCertForAzure() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver *Driver) sshKeyPath() string {
|
func (driver *Driver) sshKeyPath() string {
|
||||||
return path.Join(driver.storePath, "id_rsa")
|
return filepath.Join(driver.storePath, "id_rsa")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver *Driver) publicSSHKeyPath() string {
|
func (driver *Driver) publicSSHKeyPath() string {
|
||||||
|
@ -551,5 +551,5 @@ func (driver *Driver) publicSSHKeyPath() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (driver *Driver) azureCertPath() 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"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.google.com/p/goauth2/oauth"
|
"code.google.com/p/goauth2/oauth"
|
||||||
|
@ -318,7 +318,7 @@ func (d *Driver) getClient() *godo.Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) sshKeyPath() string {
|
func (d *Driver) sshKeyPath() string {
|
||||||
return path.Join(d.storePath, "id_rsa")
|
return filepath.Join(d.storePath, "id_rsa")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) publicSSHKeyPath() string {
|
func (d *Driver) publicSSHKeyPath() string {
|
||||||
|
|
|
@ -15,7 +15,7 @@ func GetHomeDir() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func PublicKeyPath() 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 {
|
func AddPublicKeyToAuthorizedHosts(d Driver, authorizedKeysPath string) error {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -221,7 +221,7 @@ func (d *Driver) Create() error {
|
||||||
"--port", "0",
|
"--port", "0",
|
||||||
"--device", "0",
|
"--device", "0",
|
||||||
"--type", "dvddrive",
|
"--type", "dvddrive",
|
||||||
"--medium", path.Join(d.storePath, "boot2docker.iso")); err != nil {
|
"--medium", filepath.Join(d.storePath, "boot2docker.iso")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ func (d *Driver) GetSSHCommand(args ...string) (*exec.Cmd, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) sshKeyPath() string {
|
func (d *Driver) sshKeyPath() string {
|
||||||
return path.Join(d.storePath, "id_rsa")
|
return filepath.Join(d.storePath, "id_rsa")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) publicSSHKeyPath() string {
|
func (d *Driver) publicSSHKeyPath() string {
|
||||||
|
@ -454,7 +454,7 @@ func (d *Driver) publicSSHKeyPath() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) diskPath() 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").
|
// 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 {
|
if err := f.Close(); err != nil {
|
||||||
return err
|
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 err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
6
host.go
6
host.go
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
|
@ -105,7 +105,7 @@ func (h *Host) GetURL() (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Host) LoadConfig() 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ func (h *Host) SaveConfig() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
14
store.go
14
store.go
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/machine/drivers"
|
"github.com/docker/machine/drivers"
|
||||||
|
@ -16,7 +16,7 @@ type Store struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStore() *Store {
|
func NewStore() *Store {
|
||||||
rootPath := path.Join(drivers.GetHomeDir(), ".docker/hosts")
|
rootPath := filepath.Join(drivers.GetHomeDir(), ".docker", "hosts")
|
||||||
return &Store{Path: rootPath}
|
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)
|
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)
|
host, err := NewHost(name, driverName, hostPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -95,7 +95,7 @@ func (s *Store) List() ([]Host, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) Exists(name string) (bool, 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) {
|
if os.IsNotExist(err) {
|
||||||
return false, nil
|
return false, nil
|
||||||
} else if err == 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) {
|
func (s *Store) Load(name string) (*Host, error) {
|
||||||
hostPath := path.Join(s.Path, name)
|
hostPath := filepath.Join(s.Path, name)
|
||||||
return LoadHost(name, hostPath)
|
return LoadHost(name, hostPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ func (s *Store) IsActive(host *Host) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) SetActive(host *Host) 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 err
|
||||||
}
|
}
|
||||||
return ioutil.WriteFile(s.activePath(), []byte(host.Name), 0600)
|
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
|
// activePath returns the path to the file that stores the name of the
|
||||||
// active host
|
// active host
|
||||||
func (s *Store) activePath() string {
|
func (s *Store) activePath() string {
|
||||||
return path.Join(s.Path, ".active")
|
return filepath.Join(s.Path, ".active")
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/machine/drivers"
|
"github.com/docker/machine/drivers"
|
||||||
|
@ -26,7 +27,7 @@ func (d DriverOptionsMock) Bool(key string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func clearHosts() error {
|
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) {
|
func TestStoreCreate(t *testing.T) {
|
||||||
|
@ -49,7 +50,7 @@ func TestStoreCreate(t *testing.T) {
|
||||||
if host.Name != "test" {
|
if host.Name != "test" {
|
||||||
t.Fatal("Host name is incorrect")
|
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) {
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||||
t.Fatalf("Host path doesn't exist: %s", path)
|
t.Fatalf("Host path doesn't exist: %s", path)
|
||||||
}
|
}
|
||||||
|
@ -71,7 +72,7 @@ func TestStoreRemove(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
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) {
|
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||||
t.Fatalf("Host path doesn't exist: %s", path)
|
t.Fatalf("Host path doesn't exist: %s", path)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue