task

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: Apache-2.0 Imports: 67 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Java ecosystem labels
	Java  = "java"
	Maven = "maven"

	// Go ecosystem labels
	Go     = "go"
	Golang = "golang"

	// JavaScript ecosystem labels
	JavaScript = "javascript"
	Node       = "node"
	NPM        = "npm"
)

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 cataloging.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 {
	ComplianceConfig     cataloging.ComplianceConfig
	SearchConfig         cataloging.SearchConfig
	RelationshipsConfig  cataloging.RelationshipsConfig
	DataGenerationConfig cataloging.DataGenerationConfig
	LicenseConfig        cataloging.LicenseConfig
	PackagesConfig       pkgcataloging.Config
	FilesConfig          filecataloging.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 Factories added in v1.20.0

type Factories []factory

func DefaultFileTaskFactories added in v1.20.0

func DefaultFileTaskFactories() Factories

func DefaultPackageTaskFactories

func DefaultPackageTaskFactories() Factories

func (Factories) Tasks added in v1.20.0

func (f Factories) Tasks(cfg CatalogingFactoryConfig) ([]Task, 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 Selection

type Selection struct {
	Request      cataloging.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.

func SelectInGroups added in v1.20.0

func SelectInGroups(taskGroups [][]Task, selectionRequest cataloging.SelectionRequest) ([][]Task, Selection, error)

SelectInGroups is a convenience function that allows for selecting tasks from multiple groups of tasks. The original request is split into sub-requests, where only tokens that are relevant to the given group of tasks are considered. If tokens are passed that are not relevant to any group of tasks, an error is returned.

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 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

func NewUnknownsLabelerTask added in v1.14.0

func NewUnknownsLabelerTask(cfg cataloging.UnknownsConfig) 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