alias

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractTemplateVariables

func ExtractTemplateVariables(input string) []string

ExtractTemplateVariables finds all {{ ... }} template variables and returns their paths. Whitespace around the variable name is trimmed and duplicates are removed preserving order.

func GetResolvedAliases

func GetResolvedAliases(ctx *Context) map[string]string

GetResolvedAliases returns all aliases with their resolved values

func HasUnresolvedVariables

func HasUnresolvedVariables(input string) bool

HasUnresolvedVariables returns true if input contains any unresolved template variables.

func IsSecretPath

func IsSecretPath(path string) bool

IsSecretPath reports whether an alias path names credential material that must be redacted from API responses.

func Substitute

func Substitute(input string, ctx *Context) string

Substitute replaces all alias placeholders in a string with reflected/resolved values

func ValidateTemplate

func ValidateTemplate(input string) ([]string, error)

ValidateTemplate checks template string syntax, balanced delimiters, and variable prefixes.

func ValidateTemplateVariables

func ValidateTemplateVariables(input string, ctx *Context) ([]string, error)

ValidateTemplateVariables validates template syntax and checks that all variables can be resolved with ctx.

Types

type Category

type Category string

Category groups aliases by their source type

const (
	CategoryServer  Category = "server"
	CategoryModule  Category = "module"
	CategorySpecial Category = "special"
)

type Context

type Context struct {
	Server       *models.Server
	ServerConfig *models.ServerConfig
	Module       *models.Module
	Modules      map[string]*models.Module // Sibling modules by name (for inter-module references)
	Host         *Host
	Config       *config.Config
}

Context holds the objects available for alias resolution

func NewContext

func NewContext() *Context

NewContext creates a context with host information populated

type Host

type Host struct {
	UID      int    `json:"uid"`
	GID      int    `json:"gid"`
	Hostname string `json:"hostname"`
}

Host contains host system information for alias resolution

type Info

type Info struct {
	Alias        string // e.g., "{{server.id}}"
	Path         string // e.g., "server.id"
	Description  string // From struct tag or generated
	Category     Category
	ExampleValue string // Resolved value when context available
	FieldType    string // Go type name
}

Info contains metadata about an available alias

func GetAvailableAliases

func GetAvailableAliases(ctx *Context) []Info

GetAvailableAliases returns all available aliases with their metadata

Jump to

Keyboard shortcuts

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