filter

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package filter provides helpers for filtering objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchTags

func MatchTags(filter TagClause, tags []string) bool

MatchTags tells if the filter matches the provided tags list.

func MatchTagsFrom

func MatchTagsFrom(filters []string, tags []string) (bool, error)

MatchTagsFrom tells if the filters match the provided tags list.

Types

type Operation

type Operation int

Operation is the binary logic operation (OR, AND).

const (
	// EQ is the equal operation.
	EQ Operation = iota + 1
	// NEQ is the not-equal operation.
	NEQ
	// AND is the and operation.
	AND
	// OR is the or operation.
	OR
)

type TagClause

type TagClause struct {
	// Op is the clause operation logic.
	Op Operation
	// Tag is the tag name if this is a leaf node.
	Tag string
	// Children is the list of children branches (if any)
	Children []TagClause
}

TagClause represents a tag filter clause.

func ParseTagClauses

func ParseTagClauses(filters ...string) (TagClause, bool, error)

ParseTagClauses parses the list of filters provided into a TagClause matcher. It returns a boolean telling if the clauses are not empty.

func (TagClause) IsEmpty

func (t TagClause) IsEmpty() bool

IsEmpty tells if clause is empty

Jump to

Keyboard shortcuts

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