task

package
v0.105.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 55 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyToken       = fmt.Errorf("no value given")
	ErrInvalidToken     = fmt.Errorf("invalid token given: only alphanumeric characters and hyphens are allowed")
	ErrInvalidOperator  = fmt.Errorf("invalid operator given")
	ErrUnknownNameOrTag = fmt.Errorf("unknown name or tag given")
	ErrTagsNotAllowed   = fmt.Errorf("tags are not allowed with this operation (must use exact names)")
	ErrNamesNotAllowed  = fmt.Errorf("names are not allowed with this operation (must use tags)")
	ErrAllNotAllowed    = fmt.Errorf("cannot use the 'all' operand in this context")
)

Functions

func Select

func Select(allTasks []Task, selectionRequest pkgcataloging.SelectionRequest) ([]Task, Selection, error)

Select parses the given expressions as two sets: expressions that represent a "set" operation, and expressions that represent all other operations. The parsed expressions are then evaluated against the given tasks to return a subset (or the same) set of tasks.

Types

type CatalogingFactoryConfig

type CatalogingFactoryConfig struct {
	SearchConfig         cataloging.SearchConfig
	RelationshipsConfig  cataloging.RelationshipsConfig
	DataGenerationConfig cataloging.DataGenerationConfig
	PackagesConfig       pkgcataloging.Config
}

func DefaultCatalogingFactoryConfig

func DefaultCatalogingFactoryConfig() CatalogingFactoryConfig

type ErrInvalidExpression

type ErrInvalidExpression struct {
	Expression string
	Operation  Operation
	Err        error
}

ErrInvalidExpression represents an expression that cannot be parsed or can be parsed but is logically invalid.

func (ErrInvalidExpression) Error

func (e ErrInvalidExpression) Error() string

type Executor

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

func NewTaskExecutor

func NewTaskExecutor(tasks []Task, numWorkers int) *Executor

func (*Executor) Execute

type Expression

type Expression struct {
	Operation Operation
	Operand   string
	Errors    []error
}

Expression represents a single operation-operand pair with (all validation errors). E.g. "+foo", "-bar", or "something" are all expressions. Some validations are relevant to not only the syntax (operation and operator) but other are sensitive to the context of the operand (e.g. if a given operand is a tag or a name, validated against the operation).

func (Expression) String

func (e Expression) String() string

type Expressions

type Expressions []Expression

Expressions represents a list of expressions.

func (Expressions) Clone

func (e Expressions) Clone() Expressions

func (Expressions) Errors

func (e Expressions) Errors() (errs []error)

func (Expressions) Len

func (e Expressions) Len() int

func (Expressions) Less

func (e Expressions) Less(i, j int) bool

func (Expressions) Swap

func (e Expressions) Swap(i, j int)

func (Expressions) Validate

func (e Expressions) Validate() error

type Operation

type Operation string

Operation represents the type of operation to perform on the operand (set, add, remove, sub-select).

const (
	SetOperation       Operation = "set"
	AddOperation       Operation = "add"
	SubSelectOperation Operation = "sub-select"
	RemoveOperation    Operation = "remove"
)

type PackageTaskFactories

type PackageTaskFactories []packageTaskFactory

func DefaultPackageTaskFactories

func DefaultPackageTaskFactories() PackageTaskFactories

func (PackageTaskFactories) Tasks

type Selection

type Selection struct {
	Request      pkgcataloging.SelectionRequest
	Result       *strset.Set
	TokensByTask map[string]TokenSelection
}

Selection represents the users request for a subset of tasks to run and the resulting set of task names that were selected. Additionally, all tokens that were matched on to reach the returned conclusion are also provided.

type Selector

type Selector interface {
	HasAllSelectors(...string) bool
	Selectors() []string
}

type Task

type Task interface {
	Name() string
	Execute(context.Context, file.Resolver, sbomsync.Builder) error
}

Task is a function that can wrap a cataloger to populate the SBOM with data (coordinated through the mutex).

func NewEnvironmentTask

func NewEnvironmentTask() Task

func NewExecutableCatalogerTask added in v0.104.0

func NewExecutableCatalogerTask(selection file.Selection, cfg executable.Config) Task

func NewFileContentCatalogerTask

func NewFileContentCatalogerTask(cfg filecontent.Config) Task

func NewFileDigestCatalogerTask

func NewFileDigestCatalogerTask(selection file.Selection, hashers ...crypto.Hash) Task

func NewFileMetadataCatalogerTask

func NewFileMetadataCatalogerTask(selection file.Selection) Task

func NewPackageTask

func NewPackageTask(cfg CatalogingFactoryConfig, c pkg.Cataloger, tags ...string) Task

NewPackageTask creates a Task function for a generic pkg.Cataloger, honoring the common configuration options.

func NewRelationshipsTask

func NewRelationshipsTask(cfg cataloging.RelationshipsConfig, src source.Description) Task

func NewTask

func NewTask(name string, tsk func(context.Context, file.Resolver, sbomsync.Builder) error, tags ...string) Task

type TokenSelection

type TokenSelection struct {
	SelectedOn   *strset.Set
	DeselectedOn *strset.Set
}

TokenSelection represents the tokens that were matched on to either include or exclude a given task (based on expression evaluation).

Jump to

Keyboard shortcuts

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