controller

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeSR

func MergeSR(source *claircore.IndexReport, merge []*claircore.IndexReport) *claircore.IndexReport

MergeSR merges IndexReports.

source is the IndexReport that the indexer is working on. merge is an array IndexReports returned from coalescers

Types

type Controller

type Controller struct {
	// holds dependencies for a indexer.controller
	*indexer.Opts
	// contains filtered or unexported fields
}

Controller is a control structure for scanning a manifest.

Controller is implemented as an FSM.

func New

func New(opts *indexer.Opts) *Controller

New constructs a controller given an Opts struct

func (*Controller) Index

func (s *Controller) Index(ctx context.Context, manifest *claircore.Manifest) *claircore.IndexReport

Index kicks off an index of a particular manifest. Initial state set in constructor. Call Lock() before using and Unlock() when finished scanning.

func (*Controller) Lock

func (s *Controller) Lock(ctx context.Context, hash string) error

func (*Controller) Unlock

func (s *Controller) Unlock() error

type State

type State int

State is a specific state in the indexer fsm

const (
	// Terminal is the state which halts the fsm and returns the current s.result to the caller
	Terminal State = iota
	// CheckManifest determines if the manifest should be scanned.
	// if no Terminal is returned and we return the existing IndexReport.
	// Transitions: FetchLayers, Terminal
	CheckManifest
	// FetchLayers retrieves all the layers in a manifest and stacks them the same obtain the file image contents.
	// creates the "image" layer
	// Transitions: LayerScan
	FetchLayers
	// ScanLayers scans each image including the image layer and indexes the contents
	// Transitions: BuildLayerResult
	ScanLayers
	// Coalesce runs each provided ecosystem's coalescer and merges their scan results
	// Transitions: IndexManifest
	Coalesce
	// IndexManifest evaluates a coalesced IndexReport and writes it's contents
	// to the the persistence layer where it maybe searched.
	// Transitions: IndexFinished
	IndexManifest
	// IndexError state indicates a impassable error has occurred.
	// returns a ScanResult with the error field
	// Transitions: Terminal
	IndexError
	// IndexFinished state is the terminal state and should return a IndexReport
	// to the caller of Scan()
	// Transitions: Terminal
	IndexFinished
)

States and their explanations. Each state is implemented by a stateFunc implemented in their own files.

func (*State) FromString

func (ss *State) FromString(state string)

func (State) MarshalJSON

func (ss State) MarshalJSON() ([]byte, error)

func (State) String

func (ss State) String() string

func (*State) UnmarshalJSON

func (ss *State) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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