mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Vendor in latest buildah and imagebuilder
We want to add the latest support for COPY --chown UID:GID. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #1289 Approved by: TomSweeneyRedHat
This commit is contained in:

committed by
Atomic Bot

parent
89a9750b6d
commit
57e1600315
5
vendor/github.com/openshift/imagebuilder/builder.go
generated
vendored
5
vendor/github.com/openshift/imagebuilder/builder.go
generated
vendored
@ -27,6 +27,9 @@ type Copy struct {
|
||||
Src []string
|
||||
Dest string
|
||||
Download bool
|
||||
// If set, the owner:group for the destination. This value is passed
|
||||
// to the executor for handling.
|
||||
Chown string
|
||||
}
|
||||
|
||||
// Run defines a run operation required in the container.
|
||||
@ -51,7 +54,7 @@ func (logExecutor) Preserve(path string) error {
|
||||
|
||||
func (logExecutor) Copy(excludes []string, copies ...Copy) error {
|
||||
for _, c := range copies {
|
||||
log.Printf("COPY %v -> %s (from:%s download:%t)", c.Src, c.Dest, c.From, c.Download)
|
||||
log.Printf("COPY %v -> %s (from:%s download:%t), chown: %s", c.Src, c.Dest, c.From, c.Download, c.Chown)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
7
vendor/github.com/openshift/imagebuilder/dispatchers.go
generated
vendored
7
vendor/github.com/openshift/imagebuilder/dispatchers.go
generated
vendored
@ -149,18 +149,21 @@ func dispatchCopy(b *Builder, args []string, attributes map[string]bool, flagArg
|
||||
}
|
||||
last := len(args) - 1
|
||||
dest := makeAbsolute(args[last], b.RunConfig.WorkingDir)
|
||||
var chown string
|
||||
var from string
|
||||
if len(flagArgs) > 0 {
|
||||
for _, arg := range flagArgs {
|
||||
switch {
|
||||
case strings.HasPrefix(arg, "--chown="):
|
||||
chown = strings.TrimPrefix(arg, "--chown=")
|
||||
case strings.HasPrefix(arg, "--from="):
|
||||
from = strings.TrimPrefix(arg, "--from=")
|
||||
default:
|
||||
return fmt.Errorf("COPY only supports the --from=<image|stage> flag")
|
||||
return fmt.Errorf("COPY only supports the --chown=<uid:gid> and the --from=<image|stage> flags")
|
||||
}
|
||||
}
|
||||
}
|
||||
b.PendingCopies = append(b.PendingCopies, Copy{From: from, Src: args[0:last], Dest: dest, Download: false})
|
||||
b.PendingCopies = append(b.PendingCopies, Copy{From: from, Src: args[0:last], Dest: dest, Download: false, Chown: chown})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
13
vendor/github.com/openshift/imagebuilder/internals.go
generated
vendored
13
vendor/github.com/openshift/imagebuilder/internals.go
generated
vendored
@ -46,12 +46,23 @@ func handleJSONArgs(args []string, attributes map[string]bool) []string {
|
||||
return []string{strings.Join(args, " ")}
|
||||
}
|
||||
|
||||
func hasSlash(input string) bool {
|
||||
return strings.HasSuffix(input, string(os.PathSeparator)) || strings.HasSuffix(input, string(os.PathSeparator)+".")
|
||||
}
|
||||
|
||||
// makeAbsolute ensures that the provided path is absolute.
|
||||
func makeAbsolute(dest, workingDir string) string {
|
||||
// Twiddle the destination when its a relative path - meaning, make it
|
||||
// relative to the WORKINGDIR
|
||||
if dest == "." {
|
||||
if !hasSlash(workingDir) {
|
||||
workingDir += string(os.PathSeparator)
|
||||
}
|
||||
dest = workingDir
|
||||
}
|
||||
|
||||
if !filepath.IsAbs(dest) {
|
||||
hasSlash := strings.HasSuffix(dest, string(os.PathSeparator)) || strings.HasSuffix(dest, string(os.PathSeparator)+".")
|
||||
hasSlash := hasSlash(dest)
|
||||
dest = filepath.Join(string(os.PathSeparator), filepath.FromSlash(workingDir), dest)
|
||||
|
||||
// Make sure we preserve any trailing slash
|
||||
|
Reference in New Issue
Block a user