Merge #2238
2238: Fix .dockerignore with globs and ! commands r=rhatdan a=rhatdan Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> <!-- Thanks for sending a pull request! Please make sure you've read and understood our contributing guidelines (https://github.com/containers/buildah/blob/master/CONTRIBUTING.md) as well as ensuring that all your commits are signed with `git commit -s`. --> #### What type of PR is this? <!-- Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request. Uncomment only one `/kind <>` line, hit enter to put that in a new line, and remove leading whitespace from that line: --> > /kind api-change > /kind bug > /kind cleanup > /kind deprecation > /kind design > /kind documentation > /kind failing-test > /kind feature > /kind flake > /kind other #### What this PR does / why we need it: #### How to verify it #### Which issue(s) this PR fixes: <!-- Automatically closes linked issue when PR is merged. Uncomment the following comment block and include the issue number or None on one line. Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`, or `None`. --> <!-- Fixes # or None --> #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? <!-- If no, just write `None` in the release-note block below. If yes, a release note is required: Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required". For more information on release notes please follow the kubernetes model: https://git.k8s.io/community/contributors/guide/release-notes.md --> ```release-note ``` Co-authored-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
commit
aba0d4dfe1
4
add.go
4
add.go
|
@ -322,10 +322,6 @@ func (b *Builder) addHelper(excludes *fileutils.PatternMatcher, extract bool, de
|
|||
if err != nil {
|
||||
return errors.Wrapf(err, "error checking if %s is an excluded path", path)
|
||||
}
|
||||
// Skip the whole directory if the pattern matches exclusively
|
||||
if res.Excludes() == 0 && res.Matches() == 1 && info.IsDir() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
// The latest match result has the highest priority,
|
||||
// which means that we only skip the filepath if
|
||||
// the last result matched.
|
||||
|
|
|
@ -1528,6 +1528,51 @@ load helpers
|
|||
run_buildah bud --signature-policy ${TESTSDIR}/policy.json ${TESTDIR}/recurse
|
||||
}
|
||||
|
||||
@test "bud copy with .dockerignore #1" {
|
||||
_prefetch alpine
|
||||
mytmpdir=${TESTDIR}/my-dir
|
||||
mkdir -p $mytmpdir/stuff/huge/usr/bin/
|
||||
(cd $mytmpdir/stuff/huge/usr/bin/; touch file1 file2)
|
||||
(cd $mytmpdir/stuff/huge/usr/; touch file3)
|
||||
|
||||
cat > $mytmpdir/.dockerignore << _EOF
|
||||
stuff/huge/*
|
||||
!stuff/huge/usr/bin/*
|
||||
_EOF
|
||||
|
||||
cat > $mytmpdir/Containerfile << _EOF
|
||||
FROM alpine
|
||||
COPY stuff /tmp/stuff
|
||||
RUN find /tmp/stuff -type f
|
||||
_EOF
|
||||
|
||||
run_buildah bud -t testbud --signature-policy ${TESTSDIR}/policy.json ${mytmpdir}
|
||||
expect_output --substring "file1"
|
||||
expect_output --substring "file2"
|
||||
! expect_output --substring "file3"
|
||||
}
|
||||
|
||||
@test "bud copy with .dockerignore #2" {
|
||||
_prefetch alpine
|
||||
mytmpdir=${TESTDIR}/my-dir1
|
||||
mkdir -p $mytmpdir/stuff/huge/usr/bin/
|
||||
(cd $mytmpdir/stuff/huge/usr/bin/; touch file1 file2)
|
||||
|
||||
cat > $mytmpdir/.dockerignore << _EOF
|
||||
stuff/huge/*
|
||||
_EOF
|
||||
|
||||
cat > $mytmpdir/Containerfile << _EOF
|
||||
FROM alpine
|
||||
COPY stuff /tmp/stuff
|
||||
RUN find /tmp/stuff -type f
|
||||
_EOF
|
||||
|
||||
run_buildah bud -t testbud --signature-policy ${TESTSDIR}/policy.json ${mytmpdir}
|
||||
! expect_output --substring "file1"
|
||||
! expect_output --substring "file2"
|
||||
}
|
||||
|
||||
@test "bud-copy-workdir" {
|
||||
target=testimage
|
||||
run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/copy-workdir
|
||||
|
|
Loading…
Reference in New Issue