summaryrefslogtreecommitdiff
path: root/vendor/github.com/openshift/imagebuilder/builder.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-03-26 11:23:46 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-03-26 13:57:27 -0400
commitfc197fb4f5c0e0d90da39fe672bce7d145272415 (patch)
tree56913b09296f1116d7d22d1bb938eba55d14c700 /vendor/github.com/openshift/imagebuilder/builder.go
parentfa6ba9b00fb5f77ead67b624be510ec50b2f4f5e (diff)
downloadpodman-fc197fb4f5c0e0d90da39fe672bce7d145272415.tar.gz
podman-fc197fb4f5c0e0d90da39fe672bce7d145272415.tar.bz2
podman-fc197fb4f5c0e0d90da39fe672bce7d145272415.zip
[NO TESTS NEEDED] Vendor in containers/buildah v1.20.0
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/openshift/imagebuilder/builder.go')
-rw-r--r--vendor/github.com/openshift/imagebuilder/builder.go36
1 files changed, 27 insertions, 9 deletions
diff --git a/vendor/github.com/openshift/imagebuilder/builder.go b/vendor/github.com/openshift/imagebuilder/builder.go
index 22dc548b9..dd8b09c05 100644
--- a/vendor/github.com/openshift/imagebuilder/builder.go
+++ b/vendor/github.com/openshift/imagebuilder/builder.go
@@ -30,6 +30,7 @@ type Copy struct {
// If set, the owner:group for the destination. This value is passed
// to the executor for handling.
Chown string
+ Chmod string
}
// Run defines a run operation required in the container.
@@ -60,7 +61,7 @@ func (logExecutor) EnsureContainerPath(path string) error {
func (logExecutor) Copy(excludes []string, copies ...Copy) error {
for _, c := range copies {
- log.Printf("COPY %v -> %s (from:%s download:%t), chown: %s", c.Src, c.Dest, c.From, c.Download, c.Chown)
+ log.Printf("COPY %v -> %s (from:%s download:%t), chown: %s, chmod %s", c.Src, c.Dest, c.From, c.Download, c.Chown, c.Chmod)
}
return nil
}
@@ -562,24 +563,41 @@ var builtinAllowedBuildArgs = map[string]bool{
"no_proxy": true,
}
-// ParseDockerIgnore returns a list of the excludes in the .dockerignore file.
+// ParseIgnore returns a list of the excludes in the specified path
+// path should be a file with the .dockerignore format
// extracted from fsouza/go-dockerclient and modified to drop comments and
// empty lines.
-func ParseDockerignore(root string) ([]string, error) {
+func ParseIgnore(path string) ([]string, error) {
var excludes []string
- ignore, err := ioutil.ReadFile(filepath.Join(root, ".dockerignore"))
- if err != nil && !os.IsNotExist(err) {
- return excludes, fmt.Errorf("error reading .dockerignore: '%s'", err)
+
+ ignores, err := ioutil.ReadFile(path)
+ if err != nil {
+ return excludes, err
}
- for _, e := range strings.Split(string(ignore), "\n") {
- if len(e) == 0 || e[0] == '#' {
+ for _, ignore := range strings.Split(string(ignores), "\n") {
+ if len(ignore) == 0 || ignore[0] == '#' {
continue
}
- excludes = append(excludes, e)
+ ignore = strings.Trim(ignore, "/")
+ if len(ignore) > 0 {
+ excludes = append(excludes, ignore)
+ }
}
return excludes, nil
}
+// ParseDockerIgnore returns a list of the excludes in the .containerignore or .dockerignore file.
+func ParseDockerignore(root string) ([]string, error) {
+ excludes, err := ParseIgnore(filepath.Join(root, ".containerignore"))
+ if err != nil && os.IsNotExist(err) {
+ excludes, err = ParseIgnore(filepath.Join(root, ".dockerignore"))
+ }
+ if err != nil && os.IsNotExist(err) {
+ return excludes, nil
+ }
+ return excludes, err
+}
+
// ExportEnv creates an export statement for a shell that contains all of the
// provided environment.
func ExportEnv(env []string) string {