Skip to content

Commit

Permalink
Use filepath everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsauter committed Aug 1, 2017
1 parent b4a3867 commit 8b5978f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
11 changes: 5 additions & 6 deletions crane/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"gopkg.in/v2/yaml"
"io/ioutil"
"os"
"path"
"path/filepath"
"sort"
"strconv"
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions crane/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/flynn/go-shlex"
"io"
"os"
"path"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -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, ":")
}
Expand Down

0 comments on commit 8b5978f

Please sign in to comment.