mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-18 18:58:32 +02:00
Fixed an issue where the image is broken if there are symlink in the destination path when ADD, COPY
This commit is contained in:
+15
-10
@@ -164,20 +164,25 @@ func IsDestDir(path string) bool {
|
||||
// If dest is a dir, copy it to /dest/relpath
|
||||
// If dest is a file, copy directly to dest
|
||||
// If source is a dir:
|
||||
// Assume dest is also a dir, and copy to dest/relpath
|
||||
// Assume dest is also a dir, and copy to dest/
|
||||
// If dest is not an absolute filepath, add /cwd to the beginning
|
||||
func DestinationFilepath(src, dest, cwd string) (string, error) {
|
||||
if IsDestDir(dest) {
|
||||
destPath := filepath.Join(dest, filepath.Base(src))
|
||||
if filepath.IsAbs(dest) {
|
||||
return destPath, nil
|
||||
}
|
||||
return filepath.Join(cwd, destPath), nil
|
||||
_, srcFileName := filepath.Split(src)
|
||||
newDest := dest
|
||||
|
||||
if IsDestDir(newDest) {
|
||||
newDest = filepath.Join(newDest, srcFileName)
|
||||
}
|
||||
if filepath.IsAbs(dest) {
|
||||
return dest, nil
|
||||
|
||||
if !filepath.IsAbs(newDest) {
|
||||
newDest = filepath.Join(cwd, newDest)
|
||||
}
|
||||
return filepath.Join(cwd, dest), nil
|
||||
|
||||
if len(srcFileName) <= 0 && !strings.HasSuffix(newDest, "/") {
|
||||
newDest += "/"
|
||||
}
|
||||
|
||||
return newDest, nil
|
||||
}
|
||||
|
||||
// URLDestinationFilepath gives the destination a file from a remote URL should be saved to
|
||||
|
||||
Reference in New Issue
Block a user