Merge pull request #10922 from thaJeztah/replace_dockerignore

replace dockerfile/dockerignore with patternmatcher/ignorefile
This commit is contained in:
Milas Bowman 2023-08-23 16:04:19 -04:00 committed by GitHub
commit bc9d696fa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 9 deletions

6
go.mod
View File

@ -14,7 +14,7 @@ require (
github.com/docker/buildx v0.11.2 github.com/docker/buildx v0.11.2
github.com/docker/cli v24.0.5+incompatible github.com/docker/cli v24.0.5+incompatible
github.com/docker/cli-docs-tool v0.6.0 github.com/docker/cli-docs-tool v0.6.0
github.com/docker/docker v24.0.5+incompatible // v24.0.5-dev github.com/docker/docker v24.0.5+incompatible
github.com/docker/go-connections v0.4.0 github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.5.0 github.com/docker/go-units v0.5.0
github.com/fsnotify/fsevents v0.1.1 github.com/fsnotify/fsevents v0.1.1
@ -24,8 +24,8 @@ require (
github.com/jonboulle/clockwork v0.4.0 github.com/jonboulle/clockwork v0.4.0
github.com/mattn/go-shellwords v1.0.12 github.com/mattn/go-shellwords v1.0.12
github.com/mitchellh/mapstructure v1.5.0 github.com/mitchellh/mapstructure v1.5.0
github.com/moby/buildkit v0.12.1 // v0.12 release branch github.com/moby/buildkit v0.12.1
github.com/moby/patternmatcher v0.5.0 github.com/moby/patternmatcher v0.6.0
github.com/moby/term v0.5.0 github.com/moby/term v0.5.0
github.com/morikuni/aec v1.0.0 github.com/morikuni/aec v1.0.0
github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/go-digest v1.0.0

4
go.sum
View File

@ -495,8 +495,8 @@ github.com/moby/buildkit v0.12.1 h1:vvMG7EZYCiQZpTtXQkvyeyj7HzT1JHhDWj+/aiGIzLM=
github.com/moby/buildkit v0.12.1/go.mod h1:adB4y0SxxX8trnrY+oEulb48ODLqPO6pKMF0ppGcCoI= github.com/moby/buildkit v0.12.1/go.mod h1:adB4y0SxxX8trnrY+oEulb48ODLqPO6pKMF0ppGcCoI=
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M7DBo= github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
github.com/moby/patternmatcher v0.5.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8=
github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c=
github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78=

View File

@ -22,8 +22,8 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/moby/buildkit/frontend/dockerfile/dockerignore"
"github.com/moby/patternmatcher" "github.com/moby/patternmatcher"
"github.com/moby/patternmatcher/ignorefile"
) )
type dockerPathMatcher struct { type dockerPathMatcher struct {
@ -133,13 +133,17 @@ func readDockerignorePatterns(repoRoot string) ([]string, error) {
} }
defer func() { _ = f.Close() }() defer func() { _ = f.Close() }()
return dockerignore.ReadAll(f) patterns, err := ignorefile.ReadAll(f)
if err != nil {
return nil, fmt.Errorf("error reading .dockerignore: %w", err)
}
return patterns, nil
} }
func DockerIgnoreTesterFromContents(repoRoot string, contents string) (*dockerPathMatcher, error) { func DockerIgnoreTesterFromContents(repoRoot string, contents string) (*dockerPathMatcher, error) {
patterns, err := dockerignore.ReadAll(strings.NewReader(contents)) patterns, err := ignorefile.ReadAll(strings.NewReader(contents))
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("error reading .dockerignore: %w", err)
} }
return NewDockerPatternMatcher(repoRoot, patterns) return NewDockerPatternMatcher(repoRoot, patterns)