mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
5ecab9e831
Currently TestBuildRenamedDockerfile fails since passing custom dockerfile paths like: docker build -f dir/file . fails on windows because those are unix paths. Instead, on windows accept windows style paths like: docker build -f dir\file . and convert them to unix style paths using the helper we have in `pkg/archive` so that daemon can correctly locate the path in the context. Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
29 lines
928 B
Go
29 lines
928 B
Go
// +build windows
|
|
|
|
package archive
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
|
|
)
|
|
|
|
// canonicalTarNameForPath returns platform-specific filepath
|
|
// to canonical posix-style path for tar archival. p is relative
|
|
// path.
|
|
func CanonicalTarNameForPath(p string) (string, error) {
|
|
// windows: convert windows style relative path with backslashes
|
|
// into forward slashes. since windows does not allow '/' or '\'
|
|
// in file names, it is mostly safe to replace however we must
|
|
// check just in case
|
|
if strings.Contains(p, "/") {
|
|
return "", fmt.Errorf("windows path contains forward slash: %s", p)
|
|
}
|
|
return strings.Replace(p, "\\", "/", -1), nil
|
|
}
|
|
|
|
func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (nlink uint32, inode uint64, err error) {
|
|
// do nothing. no notion of Rdev, Inode, Nlink in stat on Windows
|
|
return
|
|
}
|