mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-17 17:35:39 +02:00
Add support to --chown flag to ADD command
This commit is contained in:
@@ -35,6 +35,11 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// for testing
|
||||
var (
|
||||
getUIDAndGID = GetUIDAndGIDFromString
|
||||
)
|
||||
|
||||
const (
|
||||
pathSeparator = "/"
|
||||
)
|
||||
@@ -335,6 +340,21 @@ Loop:
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetUserGroup(chownStr string, env []string) (int64, int64, error) {
|
||||
if chownStr == "" {
|
||||
return DoNotChangeUID, DoNotChangeGID, nil
|
||||
}
|
||||
chown, err := ResolveEnvironmentReplacement(chownStr, env, false)
|
||||
if err != nil {
|
||||
return -1, -1, err
|
||||
}
|
||||
uid32, gid32, err := getUIDAndGID(chown, true)
|
||||
if err != nil {
|
||||
return -1, -1, err
|
||||
}
|
||||
return int64(uid32), int64(gid32), nil
|
||||
}
|
||||
|
||||
// Extract user and group id from a string formatted 'user:group'.
|
||||
// If fallbackToUID is set, the gid is equal to uid if the group is not specified
|
||||
// otherwise gid is set to zero.
|
||||
|
||||
Reference in New Issue
Block a user