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:
Daniel J Walsh
2018-08-16 16:23:09 -04:00
committed by Atomic Bot
parent 89a9750b6d
commit 57e1600315
6 changed files with 30 additions and 9 deletions

View File

@ -90,7 +90,7 @@ k8s.io/kube-openapi 275e2ce91dec4c05a4094a7b1daee5560b555ac9 https://github.com/
k8s.io/utils 258e2a2fa64568210fbd6267cf1d8fd87c3cb86e https://github.com/kubernetes/utils k8s.io/utils 258e2a2fa64568210fbd6267cf1d8fd87c3cb86e https://github.com/kubernetes/utils
github.com/mrunalp/fileutils master github.com/mrunalp/fileutils master
github.com/varlink/go master github.com/varlink/go master
github.com/projectatomic/buildah master github.com/projectatomic/buildah 3bdbcdf6488771d8cd080a38904111c95f52990e
github.com/Nvveen/Gotty master github.com/Nvveen/Gotty master
github.com/fsouza/go-dockerclient master github.com/fsouza/go-dockerclient master
github.com/openshift/imagebuilder master github.com/openshift/imagebuilder master

View File

@ -27,6 +27,9 @@ type Copy struct {
Src []string Src []string
Dest string Dest string
Download bool 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. // 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 { func (logExecutor) Copy(excludes []string, copies ...Copy) error {
for _, c := range copies { 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 return nil
} }

View File

@ -149,18 +149,21 @@ func dispatchCopy(b *Builder, args []string, attributes map[string]bool, flagArg
} }
last := len(args) - 1 last := len(args) - 1
dest := makeAbsolute(args[last], b.RunConfig.WorkingDir) dest := makeAbsolute(args[last], b.RunConfig.WorkingDir)
var chown string
var from string var from string
if len(flagArgs) > 0 { if len(flagArgs) > 0 {
for _, arg := range flagArgs { for _, arg := range flagArgs {
switch { switch {
case strings.HasPrefix(arg, "--chown="):
chown = strings.TrimPrefix(arg, "--chown=")
case strings.HasPrefix(arg, "--from="): case strings.HasPrefix(arg, "--from="):
from = strings.TrimPrefix(arg, "--from=") from = strings.TrimPrefix(arg, "--from=")
default: 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 return nil
} }

View File

@ -46,12 +46,23 @@ func handleJSONArgs(args []string, attributes map[string]bool) []string {
return []string{strings.Join(args, " ")} 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. // makeAbsolute ensures that the provided path is absolute.
func makeAbsolute(dest, workingDir string) string { func makeAbsolute(dest, workingDir string) string {
// Twiddle the destination when its a relative path - meaning, make it // Twiddle the destination when its a relative path - meaning, make it
// relative to the WORKINGDIR // relative to the WORKINGDIR
if dest == "." {
if !hasSlash(workingDir) {
workingDir += string(os.PathSeparator)
}
dest = workingDir
}
if !filepath.IsAbs(dest) { 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) dest = filepath.Join(string(os.PathSeparator), filepath.FromSlash(workingDir), dest)
// Make sure we preserve any trailing slash // Make sure we preserve any trailing slash

View File

@ -446,7 +446,12 @@ func (b *Executor) Copy(excludes []string, copies ...imagebuilder.Copy) error {
sources = append(sources, filepath.Join(b.contextDir, src)) sources = append(sources, filepath.Join(b.contextDir, src))
} }
} }
if err := b.builder.Add(copy.Dest, copy.Download, buildah.AddAndCopyOptions{}, sources...); err != nil {
options := buildah.AddAndCopyOptions{
Chown: copy.Chown,
}
if err := b.builder.Add(copy.Dest, copy.Download, options, sources...); err != nil {
return err return err
} }
} }

View File

@ -2,7 +2,7 @@ github.com/Azure/go-ansiterm master
github.com/blang/semver master github.com/blang/semver master
github.com/BurntSushi/toml master github.com/BurntSushi/toml master
github.com/containerd/continuity master github.com/containerd/continuity master
github.com/containernetworking/cni v0.6.0 github.com/containernetworking/cni v0.7.0-alpha1
github.com/seccomp/containers-golang master github.com/seccomp/containers-golang master
github.com/containers/image 216acb1bcd2c1abef736ee322e17147ee2b7d76c github.com/containers/image 216acb1bcd2c1abef736ee322e17147ee2b7d76c
github.com/containers/storage 17c7d1fee5603ccf6dd97edc14162fc1510e7e23 github.com/containers/storage 17c7d1fee5603ccf6dd97edc14162fc1510e7e23
@ -42,8 +42,7 @@ github.com/ostreedev/ostree-go aeb02c6b6aa2889db3ef62f7855650755befd460
github.com/pborman/uuid master github.com/pborman/uuid master
github.com/pkg/errors master github.com/pkg/errors master
github.com/pquerna/ffjson d49c2bc1aa135aad0c6f4fc2056623ec78f5d5ac github.com/pquerna/ffjson d49c2bc1aa135aad0c6f4fc2056623ec78f5d5ac
github.com/containers/libpod master github.com/containers/libpod d20f3a51463ce75d139dd830e19a173906b0b0cb
github.com/containers/libpod master
github.com/sirupsen/logrus master github.com/sirupsen/logrus master
github.com/syndtr/gocapability master github.com/syndtr/gocapability master
github.com/tchap/go-patricia master github.com/tchap/go-patricia master