classify

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package classify applies an ordered list of rules to a parsed stack and returns its class. It is pure: it does not know whether a rule originated from a preset or a custom config block.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result added in v0.4.0

type Result struct {
	Class      model.Class
	Attributes map[string][]string
}

Result is the outcome of classifying a stack: the chosen class, plus — for the firing rule's EmitAttributes — the sorted-unique non-null values found across the changes that rule matched. Attributes is nil when nothing emits.

func Classify

func Classify(s plan.RawStack, rules []Rule, def model.Class) Result

Classify returns the Result for the first rule that matches enough changes, or def (with no attributes) when none match.

type Rule

type Rule struct {
	Name           string
	Icon           string
	TypePattern    *regexp.Regexp // nil → match any resource type
	Actions        []string       // nil/empty → match any action; else all listed must be present
	MinCount       int            // minimum matching changes for the rule to fire (treated as 1 if <1)
	EmitAttributes []string       // attribute names to extract from matched changes
}

Rule is a single classification rule with a deliberately small matcher.

Jump to

Keyboard shortcuts

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