core

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2018 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	HubHost             string
	HubUser             string
	HubUserPassword     string
	ConcurrentScanLimit int
	UseMockMode         bool
	Port                int
	LogLevel            string
}

Config contains all configuration for Perceptor

func GetConfig

func GetConfig() (*Config, error)

GetConfig returns a configuration object to configure Perceptor

func (*Config) GetLogLevel

func (config *Config) GetLogLevel() (log.Level, error)

func (*Config) StartWatch

func (p *Config) StartWatch(handler func(fsnotify.Event))

StartWatch will start watching the Perceptor configuration file and call the passed handler function when the configuration file has changed

type Container

type Container struct {
	Image Image
	Name  string
}

func ApiContainerToCoreContainer

func ApiContainerToCoreContainer(apiContainer api.Container) *Container

func NewContainer

func NewContainer(image Image, name string) *Container

type DockerImageSha

type DockerImageSha string

type HubImageScan

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

type Image

type Image struct {
	// Name combines Host, User, and Project
	Name string
	Sha  DockerImageSha
}

func ApiImageToCoreImage

func ApiImageToCoreImage(apiImage api.Image) *Image

func NewImage

func NewImage(name string, sha DockerImageSha) *Image

func (Image) HubProjectName

func (image Image) HubProjectName() string

func (Image) HubProjectNameSearchString

func (image Image) HubProjectNameSearchString() string

func (Image) HubProjectVersionName

func (image Image) HubProjectVersionName() string

func (Image) HubProjectVersionNameSearchString

func (image Image) HubProjectVersionNameSearchString() string

func (Image) HubScanName

func (image Image) HubScanName() string

func (Image) HubScanNameSearchString

func (image Image) HubScanNameSearchString() string

func (*Image) HumanReadableName

func (image *Image) HumanReadableName() string

HumanReadableName returns a nice, easy to read string

func (*Image) PullSpec

func (image *Image) PullSpec() string

PullSpec combines Name with the image sha and should be pullable by Docker

type ImageInfo

type ImageInfo struct {
	ScanStatus             ScanStatus
	TimeOfLastStatusChange time.Time
	ScanResults            *hub.ImageScan
	ImageSha               DockerImageSha
	ImageNames             []string
}

func NewImageInfo

func NewImageInfo(sha DockerImageSha, imageName string) *ImageInfo

func (*ImageInfo) AddImageName

func (imageInfo *ImageInfo) AddImageName(imageName string)

func (*ImageInfo) FirstImageName

func (imageInfo *ImageInfo) FirstImageName() string

func (*ImageInfo) Image

func (imageInfo *ImageInfo) Image() Image

func (*ImageInfo) SetScanStatus

func (imageInfo *ImageInfo) SetScanStatus(newStatus ScanStatus)

func (*ImageInfo) TimeInCurrentScanStatus

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

type Model

type Model struct {
	// Pods is a map of "<namespace>/<name>" to pod
	Pods                map[string]Pod
	Images              map[DockerImageSha]*ImageInfo
	ImageScanQueue      []Image
	ImageHubCheckQueue  []Image
	ConcurrentScanLimit int
	Config              *Config
	HubVersion          string
}

Model is the root of the core model

func NewModel

func NewModel(config *Config, hubVersion string) *Model

func (*Model) AddImage

func (model *Model) AddImage(image Image)

AddImage adds an image to the model, sets its status to NotScanned, and adds it to the queue for hub checking.

func (*Model) AddImageToHubCheckQueue

func (model *Model) AddImageToHubCheckQueue(sha DockerImageSha)

func (*Model) AddImageToScanQueue

func (model *Model) AddImageToScanQueue(sha DockerImageSha)

func (*Model) AddPod

func (model *Model) AddPod(newPod Pod)

AddPod adds a pod and all the images in a pod to the model. If the pod is already present in the model, it will be removed and a new one created in its place. The key is the combination of the pod's namespace and name. It extract the containers and images from the pod, adding them into the cache.

func (*Model) DeletePod

func (model *Model) DeletePod(podName string)

DeletePod removes the record of a pod, but does not affect images.

func (*Model) FinishRunningScanClient

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

func (*Model) GetNextImageFromHubCheckQueue

func (model *Model) GetNextImageFromHubCheckQueue() *Image

func (*Model) GetNextImageFromScanQueue

func (model *Model) GetNextImageFromScanQueue() *Image

func (*Model) InProgressHubScans

func (model *Model) InProgressHubScans() []Image

func (*Model) InProgressScanCount

func (model *Model) InProgressScanCount() int

func (*Model) InProgressScans

func (model *Model) InProgressScans() []DockerImageSha

func (*Model) Metrics

func (model *Model) Metrics() *ModelMetrics

func (*Model) RemoveImageFromHubCheckQueue

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

func (*Model) ScanResults

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

func (*Model) ScanResultsForPod

func (model *Model) ScanResultsForPod(podName string) (int, int, string, error)

type ModelMetrics

type ModelMetrics struct {
	ScanStatusCounts    map[ScanStatus]int
	NumberOfPods        int
	NumberOfImages      int
	ContainerCounts     map[int]int
	ImageCountHistogram map[int]int
}

type Pod

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

func ApiPodToCorePod

func ApiPodToCorePod(apiPod api.Pod) *Pod

func NewPod

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

func (*Pod) QualifiedName

func (pod *Pod) QualifiedName() string

type ScanStatus

type ScanStatus int

ScanStatus describes the state of an image in perceptor

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

func (ScanStatus) MarshalJSON

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

func (ScanStatus) MarshalText

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

func (ScanStatus) String

func (status ScanStatus) String() string

Jump to

Keyboard shortcuts

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