Skip to content

Commit

Permalink
More Windows path fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Mar 19, 2019
1 parent 883faac commit 02da1e0
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions pkg/skaffold/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ func latestTag(image string, builds []build.Artifact) string {
return ""
}

// Note that we always use Unix-style paths in our destination.
func slashJoin(pfx, sfx string) string {
if pfx == "." || pfx == "" {
return sfx
}
elems := []string{
strings.TrimSuffix(pfx, "/"),
sfx,
}
return strings.Join(elems, "/")
}

func intersect(context string, syncMap map[string]string, files []string, workingDir string) (map[string]string, error) {
ret := map[string]string{}

Expand Down Expand Up @@ -152,11 +164,8 @@ func intersect(context string, syncMap map[string]string, files []string, workin
}

// Convert relative destinations to absolute via the workingDir.
// Note that we always use Unix-style paths in our destination.
if dst[0] == '/' {
dst = filepath.ToSlash(dst)
} else {
dst = filepath.ToSlash(filepath.Join(workingDir, dst))
if dst[0] != '/' {
dst = slashJoin(workingDir, dst)
}

// Record the final destination.
Expand Down Expand Up @@ -190,8 +199,8 @@ func matchTripleStarSyncMap(syncMap map[string]string, relPath string) (bool, st
if match {
// Map the paths as a tree from the prefix.
subtreePrefix := strings.Split(p, "***")[0]
subPath := strings.TrimPrefix(relPath, filepath.FromSlash(subtreePrefix))
return true, filepath.Join(dst, subPath), nil
subPath := strings.TrimPrefix(filepath.ToSlash(relPath), subtreePrefix)
return true, slashJoin(dst, subPath), nil
}
}
return false, "", nil
Expand All @@ -207,7 +216,7 @@ func matchOtherSyncMap(syncMap map[string]string, relPath string) (bool, string,
if match {
// Collapse the paths.
subPath := filepath.Base(relPath)
return true, filepath.Join(dst, subPath), nil
return true, slashJoin(dst, filepath.ToSlash(subPath)), nil
}
}
return false, "", nil
Expand Down

0 comments on commit 02da1e0

Please sign in to comment.