refs

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package refs provides functions for extracting resolver references from Go templates and CEL expressions.

Index

Constants

This section is empty.

Variables

View Source
var DefaultTemplateGlobs = []string{"*.tpl", "*.tmpl", "*.gotmpl"}

DefaultTemplateGlobs are the file extensions scanned when no glob is specified.

Functions

func ExtractFromCEL

func ExtractFromCEL(ctx context.Context, expr string) ([]string, error)

ExtractFromCEL extracts resolver references from a CEL expression.

func ExtractFromTemplate

func ExtractFromTemplate(content, leftDelim, rightDelim string) ([]string, error)

ExtractFromTemplate extracts resolver references from a Go template string.

func ExtractFromTemplateFile

func ExtractFromTemplateFile(filePath, leftDelim, rightDelim string) ([]string, error)

ExtractFromTemplateFile reads a template file and extracts resolver references.

func ExtractResolverName

func ExtractResolverName(path string) string

ExtractResolverName extracts the resolver name from a template path. e.g., "._.config.host" -> "config", ".config" -> "config"

func ParseGlobs added in v0.17.0

func ParseGlobs(glob string) []string

ParseGlobs splits a comma-separated glob string into trimmed patterns. Returns DefaultTemplateGlobs if the input is empty.

func ReadStdin

func ReadStdin(r io.Reader) (string, error)

ReadStdin reads all content from the given reader, trimming trailing newlines.

Types

type Detail added in v0.17.0

type Detail struct {
	Resolver string   `json:"resolver"`
	Fields   []string `json:"fields"`
}

Detail represents a resolver and its referenced fields.

func BuildDetails added in v0.17.0

func BuildDetails(paths []string) []Detail

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".

Jump to

Keyboard shortcuts

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