enrichment

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PatternTypeExact    = "exact"
	PatternTypeWildcard = "wildcard"
	PatternTypeRegex    = "regex"
	PatternTypePrefix   = "prefix"
)
View Source
const (
	TargetTypeAssetType   = "asset_type"
	TargetTypeProvider    = "provider"
	TargetTypeTag         = "tag"
	TargetTypeMetadataKey = "metadata_key"
	TargetTypeQuery       = "query"
)

Variables

This section is empty.

Functions

func BuildMetadataColumnRef

func BuildMetadataColumnRef(field string) string

BuildMetadataColumnRef builds a PostgreSQL column reference for a metadata field path.

func BuildPatternCondition

func BuildPatternCondition(columnRef, patternType, patternValue string, startParam int) (string, []interface{}, error)

BuildPatternCondition builds a SQL condition for pattern matching. startParam is the first $N parameter number to use.

func EvaluateMetadataRuleInMemory

func EvaluateMetadataRuleInMemory(rule EnrichmentRule, metadata map[string]interface{}) bool

EvaluateMetadataRuleInMemory checks if an asset matches a metadata rule without DB access.

func ExtractMetadataKeys

func ExtractMetadataKeys(metadata map[string]interface{}) []string

ExtractMetadataKeys extracts the top-level keys from metadata.

func GetNestedMetadataValue

func GetNestedMetadataValue(metadata map[string]interface{}, field string) interface{}

GetNestedMetadataValue extracts a value from nested metadata using dot notation.

func MatchWildcard

func MatchWildcard(pattern, value string) bool

MatchWildcard performs simple wildcard matching (* = any characters).

func RenumberParameters

func RenumberParameters(sql string) string

RenumberParameters renumbers SQL parameters from $2, $3, ... to $1, $2, ...

func ValidateRule

func ValidateRule(rule EnrichmentRule) error

ValidateRule validates the rule configuration based on its type.

Types

type AssetSignature

type AssetSignature struct {
	ID           string
	Type         string
	Providers    []string
	Tags         []string
	MetadataKeys []string
}

AssetSignature contains the key fields used for candidate rule lookup.

type CandidateRule

type CandidateRule struct {
	RuleID string
}

type EnrichmentRule

type EnrichmentRule interface {
	GetID() string
	GetRuleType() RuleType
	GetQueryExpression() *string
	GetMetadataField() *string
	GetPatternType() *string
	GetPatternValue() *string
	GetIsEnabled() bool
}

EnrichmentRule is the common interface implemented by asset rules.

type Evaluator

type Evaluator struct {
	// contains filtered or unexported fields
}

func NewEvaluator

func NewEvaluator(db *pgxpool.Pool) *Evaluator

NewEvaluator creates a new rule evaluator.

func (*Evaluator) EvaluateRuleForAsset

func (e *Evaluator) EvaluateRuleForAsset(ctx context.Context, rule EnrichmentRule, assetID string) (bool, error)

EvaluateRuleForAsset checks if a specific asset matches a rule.

func (*Evaluator) ExecuteRule

func (e *Evaluator) ExecuteRule(ctx context.Context, rule EnrichmentRule) ([]string, error)

ExecuteRule runs a rule and returns matching asset IDs.

type RuleTarget

type RuleTarget struct {
	RuleID      string
	TargetType  string
	TargetValue string
}

func ExtractRuleTargets

func ExtractRuleTargets(rule EnrichmentRule) []RuleTarget

ExtractRuleTargets analyzes a rule and extracts what it's targeting.

type RuleType

type RuleType string
const (
	RuleTypeQuery         RuleType = "query"
	RuleTypeMetadataMatch RuleType = "metadata_match"
)

Jump to

Keyboard shortcuts

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