Documentation
¶
Overview ¶
Package refs provides functions for extracting resolver references from Go templates and CEL expressions.
Index ¶
- Variables
- func ExtractFromCEL(ctx context.Context, expr string) ([]string, error)
- func ExtractFromTemplate(content, leftDelim, rightDelim string) ([]string, error)
- func ExtractFromTemplateFile(filePath, leftDelim, rightDelim string) ([]string, error)
- func ExtractResolverName(path string) string
- func ParseGlobs(glob string) []string
- func ReadStdin(r io.Reader) (string, error)
- type Detail
- type FileRefs
- type Output
- type ScanResult
Constants ¶
This section is empty.
Variables ¶
var DefaultTemplateGlobs = []string{"*.tpl", "*.tmpl", "*.gotmpl"}
DefaultTemplateGlobs are the file extensions scanned when no glob is specified.
Functions ¶
func ExtractFromCEL ¶
ExtractFromCEL extracts resolver references from a CEL expression.
func ExtractFromTemplate ¶
ExtractFromTemplate extracts resolver references from a Go template string.
func ExtractFromTemplateFile ¶
ExtractFromTemplateFile reads a template file and extracts resolver references.
func ExtractResolverName ¶
ExtractResolverName extracts the resolver name from a template path. e.g., "._.config.host" -> "config", ".config" -> "config"
func ParseGlobs ¶ added in v0.17.0
ParseGlobs splits a comma-separated glob string into trimmed patterns. Returns DefaultTemplateGlobs if the input is empty.
Types ¶
type Detail ¶ added in v0.17.0
Detail represents a resolver and its referenced fields.
func BuildDetails ¶ added in v0.17.0
BuildDetails groups raw resolver paths into resolver → fields mapping.
type FileRefs ¶ added in v0.17.0
type FileRefs struct {
Path string `json:"path"`
References []string `json:"references"`
Details []Detail `json:"details"`
}
FileRefs holds extracted resolver references for a single file.
type Output ¶
type Output struct {
Source string `json:"source" yaml:"source"`
SourceType string `json:"sourceType" yaml:"sourceType"`
References []string `json:"references" yaml:"references"`
Count int `json:"count" yaml:"count"`
}
Output represents the output structure for resolver reference extraction.
type ScanResult ¶ added in v0.17.0
type ScanResult struct {
References []string `json:"references"`
Count int `json:"count"`
Details []Detail `json:"details"`
Files []FileRefs `json:"files"`
FilesCount int `json:"filesCount"`
Warnings []string `json:"warnings,omitempty"`
}
ScanResult holds the aggregated result of a directory scan.
func ScanDirectory ¶ added in v0.17.0
func ScanDirectory(ctx context.Context, dir string, globs []string, exprType string) (*ScanResult, error)
ScanDirectory recursively scans a directory for template files matching the given glob patterns and returns aggregated resolver references from all files. The exprType must be "go-template" or "cel".