Documentation
¶
Overview ¶
discovery.go Config discovery and loading logic for smarterr
merge.go Config merging logic for smarterr
types.go Core HCL struct definitions for smarterr
Index ¶
- Constants
- func CollectTemplateVariables(tmpl *template.Template) []string
- func Debugf(format string, args ...any)
- func EnableDebug(cfg *Config)
- func EnableDebugForce()
- type Config
- type ContextKey
- type FileSystem
- type Hint
- type Parameter
- type Runtime
- type Smarterr
- type StackMatch
- type Template
- type Token
- type Transform
- type TransformStep
- type WrappedFS
Constants ¶
const ( SeverityError = "Error" SeverityWarning = "Warning" SeverityInfo = "Info" )
const ( // ConfigFileName is the name of the configuration file // that contains the configuration for smarterr. ConfigFileName = "smarterr.hcl" )
const (
SmarterrContextKey = "smarterrCallID"
)
Variables ¶
This section is empty.
Functions ¶
func CollectTemplateVariables ¶ added in v0.2.0
CollectTemplateVariables walks the template AST and returns a list of all variable names referenced.
func EnableDebug ¶
func EnableDebug(cfg *Config)
EnableDebug sets up internal debug output based on the Smarterr block in config.
Types ¶
type Config ¶
type Config struct {
Smarterr *Smarterr `hcl:"smarterr,block"`
Tokens []Token `hcl:"token,block"`
Hints []Hint `hcl:"hint,block"`
Parameters []Parameter `hcl:"parameter,block"`
StackMatches []StackMatch `hcl:"stack_match,block"`
Templates []Template `hcl:"template,block"`
Transforms []Transform `hcl:"transform,block"`
}
Config represents the top-level configuration for smarterr.
func LoadConfig ¶
func LoadConfig(ctx context.Context, fsys FileSystem, relStackPaths []string, baseDir string) (*Config, error)
LoadConfig loads and merges configuration files from a filesystem.
type ContextKey ¶ added in v0.4.0
type ContextKey string
type FileSystem ¶
type FileSystem interface {
Open(name string) (fs.File, error)
ReadFile(name string) ([]byte, error)
WalkDir(root string, fn fs.WalkDirFunc) error
Exists(name string) bool
}
FileSystem defines an interface for filesystem operations, including file existence checks.
type Runtime ¶
type Runtime struct {
Config *Config
Args map[string]any
Error error
Diagnostic diag.Diagnostic // single diagnostic for enrichment context
}
func NewRuntimeForDiagnostic ¶ added in v0.3.0
type Smarterr ¶
type Smarterr struct {
Debug bool `hcl:"debug,optional"`
TokenErrorMode *string `hcl:"token_error_mode,optional"` // "detailed", "placeholder", "empty" (default: "empty")
HintJoinChar *string `hcl:"hint_join_char,optional"`
HintMatchMode *string `hcl:"hint_match_mode,optional"` // "all" (default), "first"
}
Smarterr represents settings for how smarterr works such as debugging, token error mode, etc.
type StackMatch ¶
type Template ¶
Template represents a named text/template for formatting error messages or diagnostics.
type Token ¶
type Token struct {
Name string `hcl:"name,label"`
Source string `hcl:"source,optional"`
Parameter *string `hcl:"parameter,optional"`
StackMatches []string `hcl:"stack_matches,optional"`
Arg *string `hcl:"arg,optional"`
Context *string `hcl:"context,optional"`
Transforms []string `hcl:"transforms,optional"`
FieldTransforms map[string][]string `hcl:"field_transforms,optional"`
}
Token represents a token in the configuration, which can be used for error message formatting.
type Transform ¶
type Transform struct {
Name string `hcl:"name,label"`
Steps []TransformStep `hcl:"step,block"`
}