Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCatalogNotFound = errors.New("trait catalog not found")
ErrCatalogNotFound is returned when the catalog.yaml cannot be located.
Functions ¶
func CatalogBaseDir ¶
func CatalogBaseDir() string
CatalogBaseDir returns the directory from which traits are loaded. Traits live at <base>/traits/, ADRs at <base>/../adrs/, patterns at <base>/../patterns/.
func IsNotFoundError ¶
IsNotFoundError returns true if the error is a NotFoundError.
Types ¶
type ADRRef ¶
type ADRRef struct {
ID string `json:"id" yaml:"id"`
Title string `json:"title" yaml:"title"`
Category string `json:"category" yaml:"category"`
File string `json:"file" yaml:"file"`
}
ADRRef references a single ADR artifact within a trait.
type Catalog ¶
type Catalog struct {
Traits []TraitRef `json:"traits" yaml:"traits"`
}
Catalog holds all trait references.
func LoadCatalog ¶
LoadCatalog reads the trait catalog from the process repo or working directory.
type ConflictStrategy ¶
type ConflictStrategy int
ConflictStrategy determines how to handle conflicts.
const ( ConflictStrategyFirst ConflictStrategy = iota ConflictStrategyLast ConflictStrategyAll )
type NotFoundError ¶
type NotFoundError struct {
Name string
}
NotFoundError wraps a trait-not-found error.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type PatternRef ¶
type PatternRef struct {
ID string `json:"id" yaml:"id"`
Title string `json:"title" yaml:"title"`
Category string `json:"category" yaml:"category"`
File string `json:"file" yaml:"file"`
}
PatternRef references a single pattern artifact within a trait.
type ResolveResult ¶
type ResolveResult struct {
Traits []string
ADRs []ADRRef
Patterns []PatternRef
Conflicts []Conflict
}
ResolveResult is the output of the resolver.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves a list of trait names into a merged set of ADRs and patterns, detecting and handling conflicts.
func NewResolver ¶
NewResolver creates a new Resolver backed by the given catalog.
func (*Resolver) Resolve ¶
func (r *Resolver) Resolve(names []string) (*ResolveResult, error)
Resolve expands all named traits (including sub-traits via Uses) and collects their ADRs, patterns, and any category ownership conflicts.
func (*Resolver) ResolveConflicts ¶
func (r *Resolver) ResolveConflicts(result *ResolveResult, strategy ConflictStrategy) *ResolveResult
ResolveConflicts applies a conflict resolution strategy to a ResolveResult.
type Trait ¶
type Trait struct {
Name string `json:"name" yaml:"name"`
Version string `json:"version" yaml:"version"`
Description string `json:"description" yaml:"description"`
Uses []string `json:"uses" yaml:"uses"`
ADRs []ADRRef `json:"adrs" yaml:"adrs"` //nolint:tagliatelle // "adrs" is the correct domain key; "adRs" would be confusing
Patterns []PatternRef `json:"patterns" yaml:"patterns"`
OwnsCategories []string `json:"owns_categories" yaml:"owns_categories"` //nolint:tagliatelle // snake_case matches trait YAML file format
}
Trait is the full definition of a trait loaded from its YAML file.
func LoadTraitFromFile ¶
LoadTraitFromFile loads a trait directly from a YAML file path.
type TraitRef ¶
type TraitRef struct {
Name string `json:"name" yaml:"name"`
Version string `json:"version" yaml:"version"`
Description string `json:"description" yaml:"description"`
File string `json:"file" yaml:"file"`
Tags []string `json:"tags" yaml:"tags"`
}
TraitRef is an entry in the trait catalog index.