New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkg/archive: Canonicalize stored paths #10865
Conversation
Currently pkg/archive stores nested windows files with backslashes (e.g. `dir\`, `dir\file.txt`) and this causes tar not being correctly extracted on Linux daemon. This change assures we canonicalize all paths to unix paths and add them to tar with that name independent of platform. Fixes the following test cases for Windows CI: - TestBuildAddFileWithWhitespace - TestBuildCopyFileWithWhitespace - TestBuildAddDirContentToRoot - TestBuildAddDirContentToExistingDir - TestBuildCopyDirContentToRoot - TestBuildCopyDirContentToExistDir - TestBuildDockerignore - TestBuildEnvUsage - TestBuildEnvUsage2 Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
👍 happy CI is happy. |
ping @unclejack for archive stuffs :) |
LGTM |
// 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, "/") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is really impossible to have /
in path even escaped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LK4D4 you can't. http://stackoverflow.com/a/10708449/54929
but as a precautionary measure, I check for "/" and if it's there we just fail rather than blindly replacing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
windows is really wonderland
LGTM |
Got 2 LGTMs, what now? |
Is this supposed to fail on windows right now? |
@crosbymichael I'm not sure what you mean but if we build build context using windows CLI right now, nested paths are stored with backslashes, and therefore on linux daemon side, all those nested files are extracted as filenames with backslashes rather than going inside these directories. this fixes that. edit: per our irc convo, yes, windows CI is expected to fail for everything, we're counting down from 100 failures to a green CI at this point. |
LGTM |
pkg/archive: Canonicalize stored paths
Currently pkg/archive stores nested windows files with
backslashes (e.g.
dir\
,dir\file.txt
) and this causestar not being correctly extracted on Linux daemon.
This change assures we canonicalize all paths to unix
paths and add them to tar with that name independent of platform.
For example windows paths like
dir\foo.txt
gets stored asdir/foo.txt
and
dir\
entry gets stored asdir/
in the tar.With this change we sustain unix-style paths in Dockerfiles
and .dockerignore files. The windows daemon probably needs to
modify the logic to untar unix paths correctly on windows filesystems.
Fixes the following test cases for Windows CI:
Signed-off-by: Ahmet Alp Balkan ahmetalpbalkan@gmail.com
cc: @unclejack @tiborvass @icecrime @jfrazelle @swernli @jhowardmsft @jeffmendoza