Skip to content

Commit

Permalink
Merge pull request #3002 from rhatdan/test1
Browse files Browse the repository at this point in the history
Revert patch to allow copying of empty dirs.
  • Loading branch information
openshift-merge-robot authored Feb 12, 2021
2 parents 2e59c37 + 811822e commit 6421c84
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
13 changes: 0 additions & 13 deletions add.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,6 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
renameTarget = filepath.Base(extractDirectory)
extractDirectory = filepath.Dir(extractDirectory)
}

// if the destination is a directory that doesn't yet exist, let's copy it.
newDestDirFound := false
if (len(destStats) == 1 || len(destStats[0].Globbed) == 0) && destMustBeDirectory && !destCanBeFile {
newDestDirFound = true
}

if len(destStats) == 1 && len(destStats[0].Globbed) == 1 && destStats[0].Results[destStats[0].Globbed[0]].IsRegular {
if destMustBeDirectory {
return errors.Errorf("destination %v already exists but is not a directory", destination)
Expand Down Expand Up @@ -400,12 +393,6 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption

// Iterate through every item that matched the glob.
itemsCopied := 0

// if the destination is a directory that doesn't yet exist, let's copy it.
if newDestDirFound {
itemsCopied++
}

for _, glob := range localSourceStat.Globbed {
rel, err := filepath.Rel(contextDir, glob)
if err != nil {
Expand Down
22 changes: 0 additions & 22 deletions tests/bud.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2562,25 +2562,3 @@ _EOF
run_buildah manifest inspect testlist
expect_output --substring $digest
}

@test "bud test empty newdir" {
_prefetch alpine
mytmpdir=${TESTDIR}/my-dir
mkdir -p ${mytmpdir}
cat > $mytmpdir/Containerfile << _EOF
FROM alpine as galaxy
RUN mkdir -p /usr/share/ansible/roles /usr/share/ansible/collections
RUN echo "bar"
RUN echo "foo" > /usr/share/ansible/collections/file.txt
FROM galaxy
RUN mkdir -p /usr/share/ansible/roles /usr/share/ansible/collections
COPY --from=galaxy /usr/share/ansible/roles /usr/share/ansible/roles
COPY --from=galaxy /usr/share/ansible/collections /usr/share/ansible/collections
_EOF

run_buildah bud --layers --signature-policy ${TESTSDIR}/policy.json -t testbud $mytmpdir
expect_output --substring "COPY --from=galaxy /usr/share/ansible/collections /usr/share/ansible/collections"
}

0 comments on commit 6421c84

Please sign in to comment.