model

package
v2.1.0+incompatible Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoreContainerToAPIContainer

func CoreContainerToAPIContainer(coreContainer Container) *api.Container

CoreContainerToAPIContainer .....

func CoreModelToAPIModel

func CoreModelToAPIModel(model *Model) *api.CoreModel

CoreModelToAPIModel .....

func CorePodToAPIPod

func CorePodToAPIPod(corePod Pod) *api.Pod

CorePodToAPIPod .....

func IsLegalTransition added in v0.0.15

func IsLegalTransition(from ScanStatus, to ScanStatus) bool

IsLegalTransition .....

func ScanResults

func ScanResults(model *Model) (api.ScanResults, error)

ScanResults .....

Types

type Action

type Action interface {
	Apply(model *Model) error
}

Action .....

type AddImage

type AddImage struct {
	Image Image
}

AddImage .....

func (*AddImage) Apply

func (a *AddImage) Apply(model *Model) error

Apply .....

type AddPod

type AddPod struct {
	Pod Pod
}

AddPod .....

func (*AddPod) Apply

func (a *AddPod) Apply(model *Model) error

Apply .....

type AllImages

type AllImages struct {
	Images []Image
}

AllImages .....

func (*AllImages) Apply

func (a *AllImages) Apply(model *Model) error

Apply just adds new images. It currently does not delete any images.

type AllPods

type AllPods struct {
	Pods []Pod
}

AllPods .....

func (*AllPods) Apply

func (a *AllPods) Apply(model *Model) error

Apply .....

type Container

type Container struct {
	Image Image
	Name  string
}

Container .....

func NewContainer

func NewContainer(image Image, name string) *Container

NewContainer .....

type DeletePod

type DeletePod struct {
	PodName string
}

DeletePod .....

func (*DeletePod) Apply

func (d *DeletePod) Apply(model *Model) error

Apply .....

type DidFetchScanResults

type DidFetchScanResults struct {
	Sha         DockerImageSha
	ScanResults *hub.ScanResults
}

DidFetchScanResults .....

func (*DidFetchScanResults) Apply

func (d *DidFetchScanResults) Apply(model *Model) error

Apply .....

type DockerImageSha

type DockerImageSha string

DockerImageSha .....

func NewDockerImageSha

func NewDockerImageSha(sha string) (DockerImageSha, error)

NewDockerImageSha ensures that the sha is 64 characters.

type FinishScanClient

type FinishScanClient struct {
	Image *Image
	Err   error
}

FinishScanClient .....

func (*FinishScanClient) Apply

func (f *FinishScanClient) Apply(model *Model) error

Apply .....

type GetImages

type GetImages struct {
	Status ScanStatus
	Done   chan []DockerImageSha
}

GetImages .....

func NewGetImages

func NewGetImages(status ScanStatus) *GetImages

NewGetImages ...

func (*GetImages) Apply

func (g *GetImages) Apply(model *Model) error

Apply .....

type GetMetrics

type GetMetrics struct {
	Done chan *Metrics
}

GetMetrics .....

func NewGetMetrics

func NewGetMetrics() *GetMetrics

NewGetMetrics ...

func (*GetMetrics) Apply

func (g *GetMetrics) Apply(model *Model) error

Apply .....

type GetModel

type GetModel struct {
	Done chan *api.CoreModel
}

GetModel .....

func NewGetModel

func NewGetModel() *GetModel

NewGetModel .....

func (*GetModel) Apply

func (g *GetModel) Apply(model *Model) error

Apply .....

type GetNextImage

type GetNextImage struct {
	Done chan *Image
}

GetNextImage .....

func NewGetNextImage

func NewGetNextImage() *GetNextImage

NewGetNextImage ...

func (*GetNextImage) Apply

func (g *GetNextImage) Apply(model *Model) error

Apply .....

type GetScanResults

type GetScanResults struct {
	Done chan api.ScanResults
}

GetScanResults .....

func NewGetScanResults

func NewGetScanResults() *GetScanResults

NewGetScanResults ...

func (*GetScanResults) Apply

func (g *GetScanResults) Apply(model *Model) error

Apply .....

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 PruneOrphanedImages

type PruneOrphanedImages struct {
	CompletedImageShas chan []string
}

PruneOrphanedImages .....

func (*PruneOrphanedImages) Apply

func (p *PruneOrphanedImages) Apply(model *Model)

Apply .....

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

type StartScanClient

type StartScanClient struct {
	Sha   DockerImageSha
	Error chan error
}

StartScanClient .....

func NewStartScanClient

func NewStartScanClient(sha DockerImageSha) *StartScanClient

NewStartScanClient ...

func (*StartScanClient) Apply

func (s *StartScanClient) Apply(model *Model) error

Apply ...

type UpdatePod

type UpdatePod struct {
	Pod Pod
}

UpdatePod .....

func (*UpdatePod) Apply

func (u *UpdatePod) Apply(model *Model) error

Apply .....

Jump to

Keyboard shortcuts

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