mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-17 15:51:38 +02:00
Fix #647 Copy dir permissions
* update otiai10 to latest version which has correct permission logic
This commit is contained in:
+1
@@ -1,2 +1,3 @@
|
||||
testdata.copy
|
||||
coverage.txt
|
||||
vendor
|
||||
|
||||
+14
-1
@@ -7,6 +7,13 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const (
|
||||
// tmpPermissionForDirectory makes the destination directory writable,
|
||||
// so that stuff can be copied recursively even if any original directory is NOT writable.
|
||||
// See https://github.com/otiai10/copy/pull/9 for more information.
|
||||
tmpPermissionForDirectory = os.FileMode(0755)
|
||||
)
|
||||
|
||||
// Copy copies src to dest, doesn't matter if src is a directory or a file
|
||||
func Copy(src, dest string) error {
|
||||
info, err := os.Lstat(src)
|
||||
@@ -63,9 +70,14 @@ func fcopy(src, dest string, info os.FileInfo) error {
|
||||
// and pass everything to "copy" recursively.
|
||||
func dcopy(srcdir, destdir string, info os.FileInfo) error {
|
||||
|
||||
if err := os.MkdirAll(destdir, info.Mode()); err != nil {
|
||||
originalMode := info.Mode()
|
||||
|
||||
// Make dest dir with 0755 so that everything writable.
|
||||
if err := os.MkdirAll(destdir, tmpPermissionForDirectory); err != nil {
|
||||
return err
|
||||
}
|
||||
// Recover dir mode with original one.
|
||||
defer os.Chmod(destdir, originalMode)
|
||||
|
||||
contents, err := ioutil.ReadDir(srcdir)
|
||||
if err != nil {
|
||||
@@ -79,6 +91,7 @@ func dcopy(srcdir, destdir string, info os.FileInfo) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
module github.com/otiai10/copy
|
||||
|
||||
go 1.12
|
||||
|
||||
require github.com/otiai10/mint v1.3.0
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
|
||||
github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc=
|
||||
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
|
||||
Reference in New Issue
Block a user