model

package
v2.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLegalTransition added in v0.0.15

func IsLegalTransition(from ScanStatus, to ScanStatus) bool

IsLegalTransition .....

Types

type Container

type Container struct {
	Image Image
	Name  string
}

Container .....

func NewContainer

func NewContainer(image Image, name string) *Container

NewContainer .....

type DockerImageSha

type DockerImageSha string

DockerImageSha .....

func NewDockerImageSha

func NewDockerImageSha(sha string) (DockerImageSha, error)

NewDockerImageSha ensures that the sha is 64 characters.

type HubImageScan

type HubImageScan struct {
	Sha  DockerImageSha
	Scan *hub.ScanResults
	Err  error
}

HubImageScan .....

type Image

type Image struct {
	Repository string
	Tag        string
	Sha        DockerImageSha
	Priority   int
}

Image .....

func NewImage

func NewImage(repository string, tag string, sha DockerImageSha, priority int) *Image

NewImage .....

func (Image) HubProjectName

func (image Image) HubProjectName() string

HubProjectName .....

func (Image) HubProjectVersionName

func (image Image) HubProjectVersionName() string

HubProjectVersionName .....

func (Image) HubScanName

func (image Image) HubScanName() string

HubScanName .....

func (*Image) PullSpec

func (image *Image) PullSpec() string

PullSpec combines repository with sha and should be pullable by Docker

type ImageInfo

type ImageInfo struct {
	ScanStatus             ScanStatus
	TimeOfLastStatusChange time.Time
	TimeOfLastRefresh      time.Time
	ScanResults            *hub.ScanResults
	ImageSha               DockerImageSha
	RepoTags               []*RepoTag
	Priority               int
}

ImageInfo .....

func NewImageInfo

func NewImageInfo(sha DockerImageSha, repoTag *RepoTag, priority int) *ImageInfo

NewImageInfo .....

func (*ImageInfo) AddRepoTag

func (imageInfo *ImageInfo) AddRepoTag(repoTag *RepoTag)

AddRepoTag .....

func (*ImageInfo) FirstRepoTag

func (imageInfo *ImageInfo) FirstRepoTag() *RepoTag

FirstRepoTag .....

func (*ImageInfo) Image

func (imageInfo *ImageInfo) Image() Image

Image .....

func (*ImageInfo) SetPriority

func (imageInfo *ImageInfo) SetPriority(priority int)

SetPriority ...

func (*ImageInfo) SetScanResults

func (imageInfo *ImageInfo) SetScanResults(results *hub.ScanResults)

SetScanResults .....

func (*ImageInfo) TimeInCurrentScanStatus

func (imageInfo *ImageInfo) TimeInCurrentScanStatus() time.Duration

TimeInCurrentScanStatus .....

type ImageTransition

type ImageTransition struct {
	Sha  DockerImageSha
	From string
	To   ScanStatus
	Err  error
	Time time.Time
}

ImageTransition .....

func NewImageTransition

func NewImageTransition(sha DockerImageSha, from string, to ScanStatus, err error) *ImageTransition

NewImageTransition .....

type Metrics

type Metrics struct {
	ScanStatusCounts      map[ScanStatus]int
	NumberOfPods          int
	NumberOfImages        int
	ContainerCounts       map[int]int
	ImageCountHistogram   map[int]int
	PodStatus             map[string]int
	ImageStatus           map[string]int
	PodPolicyViolations   map[int]int
	ImagePolicyViolations map[int]int
	PodVulnerabilities    map[int]int
	ImageVulnerabilities  map[int]int
}

Metrics .....

type Model

type Model struct {
	// Pods is a map of qualified name ("<namespace>/<name>") to pod
	Pods             map[string]Pod
	Images           map[DockerImageSha]*ImageInfo
	ImageScanQueue   *util.PriorityQueue
	ImageTransitions []*ImageTransition
	// contains filtered or unexported fields
}

Model is the root of the core model

func NewModel

func NewModel() *Model

NewModel .....

func (*Model) AddImage

func (model *Model) AddImage(image Image)

AddImage ...

func (*Model) AddPod

func (model *Model) AddPod(pod Pod)

AddPod ...

func (*Model) DeletePod

func (model *Model) DeletePod(podName string)

DeletePod removes the record of a pod, but does not touch its images

func (*Model) FinishScanJob

func (model *Model) FinishScanJob(image *Image, err error)

FinishScanJob should be called when the scan client has finished.

func (*Model) GetImages

func (model *Model) GetImages(status ScanStatus) []DockerImageSha

GetImages returns images in that status

func (*Model) GetMetrics

func (model *Model) GetMetrics() *Metrics

GetMetrics calculates useful metrics for observing the progress of the model over time.

func (*Model) GetModel

func (model *Model) GetModel() *api.CoreModel

GetModel ...

func (*Model) GetNextImage

func (model *Model) GetNextImage() *Image

GetNextImage ...

func (*Model) GetScanResults

func (model *Model) GetScanResults() api.ScanResults

GetScanResults ...

func (*Model) ScanDidFinish

func (model *Model) ScanDidFinish(sha DockerImageSha, scanResults *hub.ScanResults)

ScanDidFinish should be called when: - the Hub scan finishes - upon startup, when scan results are first fetched

func (*Model) SetImages

func (model *Model) SetImages(images []Image)

SetImages ...

func (*Model) SetPods

func (model *Model) SetPods(pods []Pod)

SetPods ...

func (*Model) StartScanClient

func (model *Model) StartScanClient(sha DockerImageSha) error

StartScanClient ...

func (*Model) UpdatePod

func (model *Model) UpdatePod(pod Pod)

UpdatePod ...

type Pod

type Pod struct {
	Name       string
	UID        string
	Namespace  string
	Containers []Container
}

Pod .....

func NewPod

func NewPod(name string, uid string, namespace string, containers []Container) *Pod

NewPod .....

func (*Pod) QualifiedName

func (pod *Pod) QualifiedName() string

QualifiedName .....

type RepoTag

type RepoTag struct {
	Repository string
	Tag        string
}

RepoTag combines a Docker repository and tag

type Scan

type Scan struct {
	OverallStatus    hub.PolicyStatusType
	PolicyViolations int
	Vulnerabilities  int
}

Scan .....

type ScanStatus

type ScanStatus int

ScanStatus describes the state of an image in perceptor

const (
	ScanStatusUnknown           ScanStatus = iota
	ScanStatusInQueue           ScanStatus = iota
	ScanStatusRunningScanClient ScanStatus = iota
	ScanStatusRunningHubScan    ScanStatus = iota
	ScanStatusComplete          ScanStatus = iota
)

.....

func (ScanStatus) MarshalJSON

func (status ScanStatus) MarshalJSON() ([]byte, error)

MarshalJSON .....

func (ScanStatus) MarshalText

func (status ScanStatus) MarshalText() (text []byte, err error)

MarshalText .....

func (ScanStatus) String

func (status ScanStatus) String() string

String .....

Jump to

Keyboard shortcuts

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