agent

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuditResultStatusViolating = "violation"
	AuditResultStatusCompliant = "compliance"
	AuditResultStatusIgnored   = "ignored"
)
View Source
const AuthorizationTimeoutDuration = 2 * time.Hour

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	AccountID uuid.UUID
	ClusterID uuid.UUID
	AgentID   uuid.UUID

	MetricsSource      MetricsSource
	EntitiesSource     EntitiesSource
	AutomationExecutor AutomationExecutor
	Gateway            Gateway
	Auditor            Auditor
	// contains filtered or unexported fields
}

func New

func New(
	metricsSource MetricsSource,
	entitiesSource EntitiesSource,
	automationExecutor AutomationExecutor,
	gateway Gateway,
	logLevelHandler ChangeLogLevelHandler,
	auditor Auditor,

) *Agent

func (*Agent) Exit

func (a *Agent) Exit(exitCode int)

func (*Agent) Start

func (a *Agent) Start() error

func (*Agent) Stop

func (a *Agent) Stop() error

type AuditCommandHandler added in v3.4.0

type AuditCommandHandler func() error

type AuditResult added in v3.3.1

type AuditResult struct {
	TemplateID   *string
	ConstraintID *string
	CategoryID   *string
	Severity     *string

	Description string
	HowToSolve  string

	Status AuditResultStatus
	Msg    *string

	EntityName    *string
	EntityKind    *string
	NamespaceName *string
	ParentName    *string
	ParentKind    *string
	NodeIP        *string
	EntitySpec    map[string]interface{}
}

type AuditResultHandler added in v3.3.1

type AuditResultHandler func(auditResult []*AuditResult) error

type AuditResultStatus added in v3.4.0

type AuditResultStatus string

type Auditor added in v3.3.1

type Auditor interface {
	Start(ctx context.Context) error
	Stop() error

	HandleConstraints(constraint []*Constraint) map[string]error
	HandleAuditCommand() error
	SetAuditResultHandler(handler AuditResultHandler)
}

type Automation

type Automation struct {
	ID string

	NamespaceName  string
	ControllerName string
	ControllerKind string
	ContainerName  string

	ContainerResources ContainerResources
}

type AutomationExecutor

type AutomationExecutor interface {
	Start(ctx context.Context) error
	Stop() error
	SubmitAutomation(automation *Automation) error
	SetAutomationFeedbackHandler(handler AutomationFeedbackHandler)
}

type AutomationFeedback

type AutomationFeedback struct {
	ID string

	NamespaceName  string
	ControllerName string
	ControllerKind string
	ContainerName  string

	Status  AutomationStatus
	Message string
}

type AutomationFeedbackHandler

type AutomationFeedbackHandler func(feedback *AutomationFeedback) error

type AutomationHandler

type AutomationHandler func(automation *Automation) error

type AutomationStatus

type AutomationStatus string
const (
	AutomationExecuted AutomationStatus = "executed"
	AutomationFailed   AutomationStatus = "failed"
	AutomationSkipped  AutomationStatus = "skipped"
)

type ChangeLogLevelHandler

type ChangeLogLevelHandler func(level *LogLevel) error

type Constraint added in v3.3.1

type Constraint struct {
	Id         string
	TemplateId string
	AccountId  string
	ClusterId  string

	Name         string
	TemplateName string
	Parameters   map[string]interface{}
	Match        Match
	Code         string
	Description  string
	HowToSolve   string

	UpdatedAt  time.Time
	CategoryId string
	Severity   string
}

type ConstraintsHandler added in v3.3.1

type ConstraintsHandler func(constraints []*Constraint) map[string]error

type ContainerResources

type ContainerResources struct {
	Requests *RequestLimit
	Limits   *RequestLimit
}

type Delta

type Delta struct {
	Kind      EntityDeltaKind
	Gvrk      GroupVersionResourceKind
	Data      unstructured.Unstructured
	Parent    *ParentController
	Timestamp time.Time
}

type DeltasHandler

type DeltasHandler func(deltas []*Delta) error

type EntitiesResync

type EntitiesResync struct {
	Timestamp time.Time `json:"timestamp"`

	// map of entities kind and entities definitions
	Snapshot map[string]EntitiesResyncItem `json:"snapshot"`
}

type EntitiesResyncHandler

type EntitiesResyncHandler func(resync *EntitiesResync) error

type EntitiesResyncItem

type EntitiesResyncItem struct {
	Gvrk GroupVersionResourceKind     `json:"gvrk"`
	Data []*unstructured.Unstructured `json:"data"`
}

type EntitiesSource

type EntitiesSource interface {
	Start(ctx context.Context) error
	Stop() error

	SetDeltasHandler(handler DeltasHandler)
	SetEntitiesResyncHandler(handler EntitiesResyncHandler)
}

type EntityDeltaKind

type EntityDeltaKind string
const (
	EntityDeltaKindUpsert EntityDeltaKind = "UPSERT"
	EntityDeltaKindDelete EntityDeltaKind = "DELETE"
)

type Gateway

type Gateway interface {
	Start(ctx context.Context) error
	WaitAuthorization(timeout time.Duration) error

	SendMetrics(metrics []*Metric) error
	SendEntitiesDeltas(deltas []*Delta) error
	SendEntitiesResync(resync *EntitiesResync) error
	SendAutomationFeedback(feedback *AutomationFeedback) error
	SendAuditResults(auditResult []*AuditResult) error

	SetAutomationHandler(handler AutomationHandler)
	SetRestartHandler(handler RestartHandler)
	SetChangeLogLevelHandler(handler ChangeLogLevelHandler)
	SetConstraintsHandler(handler ConstraintsHandler)
	SetAuditCommandHandler(handler AuditCommandHandler)
}

type GroupVersionResourceKind

type GroupVersionResourceKind struct {
	schema.GroupVersionResource
	Kind string
}

type LogLevel

type LogLevel struct {
	Level string
}

type Match added in v3.3.1

type Match struct {
	Namespaces []string
	Kinds      []string
}

type Metric

type Metric struct {
	Name           string
	Type           string
	NodeName       string
	NodeIP         string
	NamespaceName  string
	ControllerName string
	ControllerKind string
	ContainerName  string
	Timestamp      time.Time
	Value          int64
	PodName        string

	AdditionalTags map[string]interface{}
}

Metric metrics struct

type MetricsHandler

type MetricsHandler func([]*Metric) error

type MetricsSource

type MetricsSource interface {
	Start(ctx context.Context) error
	Stop() error

	SetMetricsHandler(handler MetricsHandler)
}

type ParentController

type ParentController struct {
	Kind       string `json:"kind"`
	Name       string `json:"name"`
	APIVersion string `json:"api_version"`
	IsWatched  bool   `json:"is_watched"`

	Parent *ParentController `json:"parent"`
}

type RequestLimit

type RequestLimit struct {
	CPU    *int64
	Memory *int64
}

type RestartHandler

type RestartHandler func() error

Jump to

Keyboard shortcuts

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