Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComplexPatterns ¶
func ComplexPatterns(patterns []*patternmatcher.Pattern) []*patternmatcher.Pattern
ComplexPatterns checks if all patterns are prefix patterns.
Types ¶
type DockerIgnoreContext ¶
type DockerIgnoreContext struct {
// contains filtered or unexported fields
}
DockerIgnoreContext wrap a continuity.Context that filters resources based on a .dockerignore file.
func NewDockerIgnoreContext ¶
func NewDockerIgnoreContext(root string, dockerignore *DockerIgnoreFilter, opts continuity.ContextOptions) (*DockerIgnoreContext, error)
NewDockerIgnoreContext creates a new DockerIgnoreContext with a dockerignore filter.
Example ¶
package main import ( "fmt" "os" "path" "github.com/containerd/continuity" "github.com/depot/orca/filter" ) func main() { // Make some test data: root, _ := os.MkdirTemp("", "testwalk") f, err := os.Create(path.Join(root, "index.ts")) if err != nil { panic(err) } _ = f.Close() // This dockerignore filter will ignore all files in node_modules. ignoreNodeModules, err := filter.NewDockerIgnoreFilter([]string{"node_modules"}) if err != nil { panic(err) } // Create a context that will walk the file tree and filter out node_modules. ctx, err := filter.NewDockerIgnoreContext(root, ignoreNodeModules, continuity.ContextOptions{ // This digester will create chunked digests for each file. Digester: &filter.Digester{}, }) if err != nil { panic(err) } manifest, _ := continuity.BuildManifest(ctx) for _, r := range manifest.Resources { fmt.Printf("%v\n", r.Path()) } }
Output: /index.ts
func (*DockerIgnoreContext) Apply ¶
func (c *DockerIgnoreContext) Apply(r continuity.Resource) error
Apply passes through to the inner context.
func (*DockerIgnoreContext) Resource ¶
func (c *DockerIgnoreContext) Resource(p string, fi os.FileInfo) (continuity.Resource, error)
Resource passes through to the inner context.
func (*DockerIgnoreContext) Verify ¶
func (c *DockerIgnoreContext) Verify(r continuity.Resource) error
Verify passes through to the inner context.
func (*DockerIgnoreContext) Walk ¶
func (c *DockerIgnoreContext) Walk(walkFn filepath.WalkFunc) error
Walk applies a dockerignore to filter files from a directory tree. Files that are not filtered by the dockerignore are passed through to the inner context.
This was transliterated from buildkit. It has *BIG* assumption that it is ok for the same directory to be visited multiple times.
type DockerIgnoreFilter ¶
type DockerIgnoreFilter struct { Patterns []*patternmatcher.Pattern HasExclusions bool OnlySimplePatterns bool }
DockerIgnoreFilter is a filter that uses dockerignore rules to filter files from a directory tree.
This is largely transliterated from buildkit.
func NewDockerIgnoreFilter ¶
func NewDockerIgnoreFilter(patterns []string) (*DockerIgnoreFilter, error)
func (*DockerIgnoreFilter) Matches ¶
func (f *DockerIgnoreFilter) Matches(path string, parentPathMatches MatchedPatterns) (ok bool, patterns MatchedPatterns, err error)
Matches checks if the path matches the dockerignore patterns.
type MatchedPatterns ¶
type MatchedPatterns []bool
MatchIndices is a slice of booleans that indicate which patterns matched the path.