This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.
Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}
is also tedious, but `t.TempDir` handles this for us nicely.
Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
It is legal to use !./PATH and !/PATH in a .containerignore or
.dockerignore file.
Currently we fail to match on these patterns, Removing the leadking
"/" and cleaning the path, fixes the problem.
Fixes: https://github.com/containers/buildah/issues/3272
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
With Go 1.16 and later, pkg/fileutils.NewPatternMatcher() will flag
patterns with bad syntax immediately. With older compilers, it would
have returned a matcher object which flagged syntax errors only when the
matcher was actually used to check a path. Update tests to accept
either behavior.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Currently, double star exclude patterns are only able to match files. They
should also match directories.
Signed-off-by: Yann Soubeyrand <yann.soubeyrand@camptocamp.com>
Exclude patterns ending with a single slash are invalid and lead to a regexp
wrongly matching a dollar at the end of the file path. Error out instead of
building a bad regexp.
Signed-off-by: Yann Soubeyrand <yann.soubeyrand@camptocamp.com>
This information is needed as well if we want to match
in a way that the last match has the highest priority.
We now introduce a new method `MatchesResult` to not break the previous
API.
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
We now add the information how many exclusions a match has, which is
needed for more fine-granular filepath matching.
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
The `pure` indicator for a match now returns `true` if it's the only
one. This additional information will be used by consumers to decide
more fine-granular if a match can be excluded completely or not.
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Had to vendor in a new version of golang.org/x/net to build
Also had to make some changes to drivers to handle
archive.Reader -> io.Reader
archive.Archive -> io.ReadCloser
Also update .gitingore to ignore emacs files, containers-storage.*
and generated man pages.
Also no longer test travis against golang 1.7, cri-o, moby have also
done this.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>