filter

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 5 Imported by: 72

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	FilterLines []string
	// contains filtered or unexported fields
}

A Filter contains a list of regular expressions matching pathnames which should be filtered out: excluded when building or not changed when pushing images to a sub. A Filter with no lines is an empty filter (nothing is excluded, everything is changed when pushing). A nil *Filter is a sparse filter: when building nothing is excluded. When pushing to a sub, all files are pushed but files on the sub which are not in the image are not removed from the sub.

func Load

func Load(filename string) (*Filter, error)

Load will load a Filter from a file containing newline separated regular expressions.

func New

func New(filterLines []string) (*Filter, error)

New will create a Filter from a list of regular expressions, which are automatically anchored to the beginning of the string to be matched against. If filterLines is of length zero the Filter is an empty Filter.

func Read

func Read(reader io.Reader) (*Filter, error)

Read will read a Filter from a reader containing newline separated regular expressions.

func (*Filter) Compile

func (filter *Filter) Compile() error

Compile will compile the regular expression strings for later use.

func (*Filter) Equal added in v0.3.2

func (left *Filter) Equal(right *Filter) bool

Equal will return true if two filters contain the same filter lines.

func (*Filter) Match

func (filter *Filter) Match(pathname string) bool

Match will return true if pathname matches one of the regular expressions. The Compile method will be automatically called if it has not been called yet.

func (*Filter) RegisterStrings added in v0.3.3

func (filter *Filter) RegisterStrings(registerFunc func(string))

RegisterStrings may be used to register the regular expression strings with a string de-duper. This can be used for garbage collection.

func (*Filter) ReplaceStrings

func (filter *Filter) ReplaceStrings(replaceFunc func(string) string)

ReplaceStrings may be used to replace the regular expression strings with de-duplicated copies.

func (*Filter) Write added in v0.3.2

func (filter *Filter) Write(writer io.Writer) error

Write will write the filter as newline separated regular expressions.

type MergeableFilter

type MergeableFilter struct {
	// contains filtered or unexported fields
}

A MergeableFilter may be used to combine multiple Filters, eliminating duplicate match expressions.

func (*MergeableFilter) ExportFilter

func (mf *MergeableFilter) ExportFilter() *Filter

ExportFilter will return a Filter from previously merged Filters.

func (*MergeableFilter) Merge

func (mf *MergeableFilter) Merge(filter *Filter)

Merge will merge a Filter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL