-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Cannot COPY file to existing directory without trailing slash #365
Comments
@Zetten I agree that currently
and Perhaps we should check if the directory exists first, and if not then check the string? If you're still interested in opening a PR for this, that would be great! |
Add a check for FileInfo to determine whether a given string is a directory path. If any error occurs, fall back to the naive string check. Fixes GoogleContainerTools#365
The PR tries to avoid any repercussions of changing IsDestDir, but it's used in a few places and not always to check real filesystems. I'm not so hot with go but I've tried to keep it as simple and defensive as I can. For the same reason, I've also missed out testing this - it hasn't broken the existing stuff, but with some guidance I can try adding a new test. |
Add a check for FileInfo to determine whether a given string is a directory path. If any error occurs, fall back to the naive string check. Fixes GoogleContainerTools#365
Actual behavior
A Dockerfile with content
will fail to build in Kaniko, with the error:
error building image: error building stage: open /path/to/foo: is a directory
Expected behavior
docker build
is rather more lenient with the target for COPY commands, and will create the file in the destination directory:/path/to/foo/sourcefile
.Additional Information
I've tried tracking down the problem through the
DestinationFilepath
function incommand_util.go
. This checks whether the destination is a directory using theIsDestDir
function. HoweverIsDestDir
is quite naive and string-based, and only checks for the existence of a trailing slash or cwd marker - which are not present in the example above.Changing
IsDestDir
seems like it may have side effects in other places, but I managed to test successfully with a new function, replacing theIsDestDir
call inDestinationFilepath
:It's not clear to me whether this is the best approach, nor how to properly test it. I'm happy to create a PR with some feedback!
The text was updated successfully, but these errors were encountered: