From 8b5978f79dee9c846d651d7ac2f1c1ae976f604d Mon Sep 17 00:00:00 2001 From: Michael Sauter Date: Tue, 1 Aug 2017 20:22:59 +0200 Subject: [PATCH] Use filepath everywhere --- crane/config.go | 11 +++++------ crane/container.go | 5 ++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/crane/config.go b/crane/config.go index 44fc233..5014057 100644 --- a/crane/config.go +++ b/crane/config.go @@ -9,7 +9,6 @@ import ( "gopkg.in/v2/yaml" "io/ioutil" "os" - "path" "path/filepath" "sort" "strconv" @@ -147,7 +146,7 @@ func readConfig(configPath string, files []string) *config { for _, f := range files { filename := filepath.Base(f) - absFile := path.Join(configPath, filename) + absFile := filepath.Join(configPath, filename) if _, err := os.Stat(absFile); err == nil { fileConfig := readFile(absFile) if config == nil { @@ -166,8 +165,8 @@ func readConfig(configPath string, files []string) *config { func findConfigPath(files []string) string { // If the first of the locations array is specified as an absolute // path, we use its directory as the config path. - if path.IsAbs(files[0]) { - return path.Dir(files[0]) + if filepath.IsAbs(files[0]) { + return filepath.Dir(files[0]) } // Otherwise, we traverse directories upwards, until we find a @@ -176,13 +175,13 @@ func findConfigPath(files []string) string { configPath, _ := os.Getwd() for { for _, f := range files { - filename := path.Join(configPath, f) + filename := filepath.Join(configPath, f) if _, err := os.Stat(filename); err == nil { return configPath } } // Loop only if we haven't yet reached the root - if parentPath := path.Dir(configPath); len(parentPath) != len(configPath) { + if parentPath := filepath.Dir(configPath); len(parentPath) != len(configPath) { configPath = parentPath } else { break diff --git a/crane/container.go b/crane/container.go index 4bd9fda..662daeb 100644 --- a/crane/container.go +++ b/crane/container.go @@ -7,7 +7,6 @@ import ( "github.com/flynn/go-shlex" "io" "os" - "path" "path/filepath" "strconv" "strings" @@ -1585,8 +1584,8 @@ func actualVolumeArg(volume string) string { parts := strings.Split(volume, ":") if includes(cfg.VolumeNames(), parts[0]) { parts[0] = cfg.Volume(parts[0]).ActualName() - } else if !path.IsAbs(parts[0]) { - parts[0] = cfg.Path() + "/" + parts[0] + } else if !filepath.IsAbs(parts[0]) { + parts[0] = cfg.Path() + fmt.Sprintf("%c", filepath.Separator) + parts[0] } return strings.Join(parts, ":") }