models

package
v0.0.76 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package models contains domain models for profiles

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionConfiguration

type ActionConfiguration struct {
	Remediate ActionOpt
	Alert     ActionOpt
}

ActionConfiguration stores the configuration state for a profile

type ActionOpt

type ActionOpt int

ActionOpt is the type that defines what action to take when remediating

const (
	// ActionOptOn means perform the remediation
	ActionOptOn ActionOpt = iota
	// ActionOptOff means do not perform the remediation
	ActionOptOff
	// ActionOptDryRun means perform a dry run of the remediation
	ActionOptDryRun
	// ActionOptUnknown means the action is unknown. This is a sentinel value.
	ActionOptUnknown
)

func ActionOptFromDB

func ActionOptFromDB(dbState db.NullActionType) ActionOpt

ActionOptFromDB converts the db representation of action type to ActionOpt

func ActionOptOrDefault

func ActionOptOrDefault(actionOpt ActionOpt, defaultVal ActionOpt) ActionOpt

ActionOptOrDefault returns defaultVal if the ActionOpt is ActionOptUnknown, or returns actionOpt otherwise

func (ActionOpt) String

func (a ActionOpt) String() string

type ProfileAggregate

type ProfileAggregate struct {
	ID           uuid.UUID
	Name         string
	ActionConfig ActionConfiguration
	Rules        []RuleInstance
	Selectors    []ProfileSelector
}

ProfileAggregate represents a profile along with rule instances

type ProfileSelector

type ProfileSelector struct {
	Entity   minderv1.Entity
	Selector string
}

ProfileSelector is a domain-level model of a profile selector

func SelectorSliceFromDB

func SelectorSliceFromDB(dbSelectors []db.ProfileSelector) []ProfileSelector

SelectorSliceFromDB converts a slice of db.ProfileSelector to a slice of ProfileSelector

type RuleInstance

type RuleInstance struct {
	ID         uuid.UUID
	Name       string
	Def        map[string]any
	Params     map[string]any
	RuleTypeID uuid.UUID
}

RuleInstance is a domain-level model of a rule instance

func RuleFromDB

func RuleFromDB(rule db.RuleInstance) (RuleInstance, error)

RuleFromDB converts a DB schema rule instance to the domain model

func RuleFromPB

func RuleFromPB(
	ruleTypeID uuid.UUID,
	pbRule *minderv1.Profile_Rule,
) RuleInstance

RuleFromPB converts a protobuf rule instance to the domain model

Jump to

Keyboard shortcuts

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