entities

package
v0.0.0-...-a443d5c Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	FactsGathererdEventSource = "https://github.com/trento-project/agent"
)

Variables

View Source
var ValueNotFoundError = FactGatheringError{
	Type:    "value-not-found",
	Message: "error getting value",
}

nolint:gochecknoglobals ValueNotFoundError is an error returned when the wanted value in GetValue function is not found

Functions

func Prettify

func Prettify(fact FactValue) (string, error)

Types

type Fact

type Fact struct {
	Name    string
	CheckID string
	Value   FactValue
	Error   *FactGatheringError
}

func NewFactGatheredWithError

func NewFactGatheredWithError(req FactRequest, err *FactGatheringError) Fact

func NewFactGatheredWithRequest

func NewFactGatheredWithRequest(factReq FactRequest, value FactValue) Fact

func NewFactsGatheredListWithError

func NewFactsGatheredListWithError(reqs []FactRequest, err *FactGatheringError) []Fact

func (*Fact) Prettify

func (e *Fact) Prettify() (string, error)

type FactGatheringError

type FactGatheringError struct {
	Message string
	Type    string
}

func (*FactGatheringError) Error

func (e *FactGatheringError) Error() string

func (*FactGatheringError) Wrap

type FactRequest

type FactRequest struct {
	Argument string
	CheckID  string
	Gatherer string
	Name     string
}

type FactValue

type FactValue interface {
	AsInterface() interface{}
	// contains filtered or unexported methods
}

FactValue represents a dynamically typed value which can be either an int, a float, a string, a boolean, a recursive map[string] value, or a list of values. A producer of FactValue is expected to set one of that variants.

func NewFactValue

func NewFactValue(factInterface interface{}, opts ...FactValueOption) (FactValue, error)

NewFactValue constructs a FactValue from a nested interface.

func ParseStringToFactValue

func ParseStringToFactValue(str string) FactValue

ParseStringToFactValue parses a string to a FactValue type.

type FactValueBool

type FactValueBool struct {
	Value bool
}

func (*FactValueBool) AsInterface

func (v *FactValueBool) AsInterface() interface{}

AsInterface converts a FactValueBool internal value to an interface{}.

type FactValueFloat

type FactValueFloat struct {
	Value float64
}

func (*FactValueFloat) AsInterface

func (v *FactValueFloat) AsInterface() interface{}

AsInterface converts a FactValueFloat internal value to an interface{}.

type FactValueInt

type FactValueInt struct {
	Value int
}

func (*FactValueInt) AsInterface

func (v *FactValueInt) AsInterface() interface{}

AsInterface converts a FactValueInt internal value to an interface{}.

type FactValueList

type FactValueList struct {
	Value []FactValue
}

func (*FactValueList) AppendValue

func (v *FactValueList) AppendValue(value FactValue)

AsInterface converts a FactValueList internal value to an interface{}.

func (*FactValueList) AsInterface

func (v *FactValueList) AsInterface() interface{}

AsInterface converts a FactValueList internal value to an interface{}.

type FactValueMap

type FactValueMap struct {
	Value map[string]FactValue
}

func (*FactValueMap) AsInterface

func (v *FactValueMap) AsInterface() interface{}

AsInterface converts a FactValueMap internal value to an interface{}.

func (*FactValueMap) GetValue

func (v *FactValueMap) GetValue(values string) (FactValue, *FactGatheringError)

GetValue returns a value using a dot access key format from a FactValue. Examples: foo.bar.buz access the {"foo": {"bar": {"baz": "value"}}} foo.0.buz access the {"foo": [{"buz": "value"}]}

type FactValueNil

type FactValueNil struct{}

func (*FactValueNil) AsInterface

func (v *FactValueNil) AsInterface() interface{}

AsInterface converts a FactValueNil internal value to an interface{}.

type FactValueOption

type FactValueOption func(f *conf)

func WithSnakeCaseKeys

func WithSnakeCaseKeys() FactValueOption

WithSnakeCaseKeys converts map keys to snake_case

func WithStringConversion

func WithStringConversion() FactValueOption

WithStringConversion enables string automatic conversion to numeric fact values

type FactValueString

type FactValueString struct {
	Value string
}

func (*FactValueString) AsInterface

func (v *FactValueString) AsInterface() interface{}

AsInterface converts a FactValueString internal value to an interface{}.

type FactsGathered

type FactsGathered struct {
	AgentID       string
	ExecutionID   string
	FactsGathered []Fact
	GroupID       string
}

type FactsGatheringRequested

type FactsGatheringRequested struct {
	ExecutionID string
	GroupID     string
	Targets     []FactsGatheringRequestedTarget
}

type FactsGatheringRequestedTarget

type FactsGatheringRequestedTarget struct {
	AgentID      string
	FactRequests []FactRequest
}

type GroupedByGathererRequestedTarget

type GroupedByGathererRequestedTarget struct {
	FactRequests map[string][]FactRequest
}

Jump to

Keyboard shortcuts

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