Documentation
¶
Index ¶
- Variables
- func BuildDashboardBuiltins() map[string]string
- func BuildMonitorBuiltins() map[string]string
- func ComputePathFromTemplate(pattern string, data any) (string, error)
- func ExtractStaticPrefix(pathTemplate string) string
- func ExtractTagMap(raw any, sanitize bool) map[string]string
- func HasAllTagsMap(tags map[string]string, filterTags []string) bool
- func HasAllTagsSlice(dashboardTags []string, filterTags []string) bool
- func TranslatePlaceholders(pattern string, builtins map[string]string) string
Constants ¶
This section is empty.
Variables ¶
var ( // PlaceholderRegex matches placeholder patterns like {word} PlaceholderRegex = regexp.MustCompile(`\{([A-Za-z0-9_\-]+)\}`) // EnvVarRegex matches environment variable naming pattern (uppercase letters, numbers, underscores) EnvVarRegex = regexp.MustCompile(`^[A-Z][A-Z0-9_]*$`) )
Functions ¶
func BuildDashboardBuiltins ¶
BuildDashboardBuiltins returns the builtins map for dashboard path templates.
func BuildMonitorBuiltins ¶
BuildMonitorBuiltins returns the builtins map for monitor path templates.
func ComputePathFromTemplate ¶
ComputePathFromTemplate executes a Go template to compute a file path. It handles template parsing and execution, returning an error if either fails. The pattern should already be translated (using TranslatePlaceholders). Returns the computed path, replacing "<no value>" with "none".
func ExtractStaticPrefix ¶
ExtractStaticPrefix returns the longest static prefix from a path template. For example, "data/dashboards/{id}.json" returns "data/dashboards". Environment variable placeholders (e.g., {MY_VAR}) and data are expanded before extraction. For example, if MY_BASE=/opt/data, then "{MY_BASE}/dashboards/{id}.json" returns "/opt/data/dashboards". This is used to determine the base directory to scan when updating existing files.
func ExtractTagMap ¶
ExtractTagMap converts a raw tags value (typically []any or []interface{}) into a map[key]value. If sanitize is true, values are sanitized via storage.SanitizeFilename.
func HasAllTagsMap ¶
HasAllTagsMap checks if tags contain all required filterTags (case-insensitive), where filterTags are in the form key:value.
func HasAllTagsSlice ¶
HasAllTagsSlice checks if all filterTags are present in dashboardTags (both lowercase for comparison).
func TranslatePlaceholders ¶
TranslatePlaceholders converts placeholders like {id} into Go template expressions. Builtins should map placeholders (e.g. "{id}") to template expressions (e.g. "{{.ID}}"). Environment variable placeholders (e.g. {MY_VAR}) are replaced with their env var values first. Any remaining {word} will be mapped to {{.Tags.word}}.
Types ¶
This section is empty.