controller

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeSR

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

MergeSR merges ScanReports.

source is the ScanReport that the scanner is working on. merge is an array ScanReports returned from coalescers

Types

type Controller

type Controller struct {
	// holds dependencies for a scanner.controller
	*scanner.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 *scanner.Opts) *Controller

New constructs a controller given an Opts struct

func (*Controller) Lock

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

func (*Controller) Scan

func (s *Controller) Scan(ctx context.Context, manifest *claircore.Manifest) *claircore.ScanReport

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

func (*Controller) Unlock

func (s *Controller) Unlock() error

type State

type State int

State is a specific state in the scanner 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 ScanReport.
	// 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 mergs their scan results
	// Transitions: ScanFinished
	Coalesce
	// ScanError state indicates a impassable error has occured.
	// returns a ScanResult with the error field
	// Transitions: Terminal
	ScanError
	// ScanFinished state is the terminal state and should return a ScanReport
	// to the caller of Scan()
	// Transitions: Terminal
	ScanFinished
)

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