Skip to content

Commit fb0788f

Browse files
committed
build: replace uses of archive.CanonicalTarNameForPath
As it's just an alias for filepath.IsAbs. Also added a normalize step in TrimBuildFilesFromExcludes, so that callers are not _required_ to first normalize the path. We are considering deprecating and/or removing this function in the archive package, so removing it in the cli code helps transitioning if we decide to deprecate and/or remove it. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 6205b4e commit fb0788f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

cli/command/image/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func runBuild(dockerCli command.Cli, options buildOptions) error {
265265
}
266266

267267
// And canonicalize dockerfile name to a platform-independent one
268-
relDockerfile = archive.CanonicalTarNameForPath(relDockerfile)
268+
relDockerfile = filepath.ToSlash(relDockerfile)
269269

270270
excludes = build.TrimBuildFilesFromExcludes(excludes, relDockerfile, options.dockerfileFromStdin())
271271
buildCtx, err = archive.TarWithOptions(contextDir, &archive.TarOptions{

cli/command/image/build/dockerignore.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ func TrimBuildFilesFromExcludes(excludes []string, dockerfile string, dockerfile
3232
if keep, _ := fileutils.Matches(".dockerignore", excludes); keep {
3333
excludes = append(excludes, "!.dockerignore")
3434
}
35+
36+
// canonicalize dockerfile name to be platform-independent.
37+
dockerfile = filepath.ToSlash(dockerfile)
3538
if keep, _ := fileutils.Matches(dockerfile, excludes); keep && !dockerfileFromStdin {
3639
excludes = append(excludes, "!"+dockerfile)
3740
}

0 commit comments

Comments
 (0)