Documentation
¶
Index ¶
- Variables
- func CheckIsVar(varKey string) bool
- func CheckPrefix(varKey string) bool
- func CheckStringHasAnyVarKey(raw string) bool
- func CheckSuffix(varKey string) bool
- func ExtractVarKeys(raw string) []string
- func ExtractVarKeysFromMultiple(strs ...string) []string
- func FilterVars(vars []menv.Variable, filter func(menv.Variable) bool) []menv.Variable
- func GetIsFileReferencePath(filePath string) string
- func GetVarKeyFromRaw(raw string) string
- func HelperNewAny(vars *[]menv.Variable, target any, prefix string)
- func IsEnvReference(key string) bool
- func IsFileReference(key string) bool
- func MergeVars(global, current []menv.Variable) []menv.Variable
- func ReadEnvValueAsString(ref string) (string, error)
- func ReadFileContentAsString(filePath string) (string, error)
- type VarMap
- type VarMapTracker
Constants ¶
This section is empty.
Variables ¶
var ( ErrKeyNotFound = fmt.Errorf("key not found") ErrInvalidKey = fmt.Errorf("invalid key") )
Functions ¶
func CheckIsVar ¶
func CheckPrefix ¶
func CheckStringHasAnyVarKey ¶
func CheckSuffix ¶
func ExtractVarKeys ¶
ExtractVarKeys extracts all variable keys from a string without resolving them. Returns a deduplicated list of variable keys (e.g., "nodeName.field", "userId"). Skips special references like #env: and #file:.
func ExtractVarKeysFromMultiple ¶
ExtractVarKeysFromMultiple extracts variable keys from multiple strings and returns a deduplicated list.
func FilterVars ¶
func GetIsFileReferencePath ¶
func IsEnvReference ¶
IsEnvReference checks if a variable key refers to an environment variable (starts with "#env:")
func IsFileReference ¶
IsFileReference checks if a variable key refers to a file (starts with "file:")
func ReadEnvValueAsString ¶
ReadEnvValueAsString resolves a #env: reference to its environment value.
func ReadFileContentAsString ¶
ReadFileContentAsString reads the content of a file at the given path
Types ¶
type VarMap ¶
func MergeVarMap ¶
MergeVarMap merges two var maps it creates a new var map and does not modify the original var maps
func NewVarMapFromAnyMap ¶
func (VarMap) ReplaceVars ¶
ReplaceVars replaces {{ varKey }} patterns with values from the VarMap.
LIMITATION: This method only does simple key lookup. It does NOT support:
- Expressions: {{ a + b }}, {{ count > 5 }}
- Function calls: {{ now() }}, {{ len(items) }}
- Only works with pre-flattened keys like "user.name" (not nested access)
RECOMMENDED: Use expression.UnifiedEnv for full expression support:
// Old way (limited): varMap := varsystem.NewVarMapFromAnyMap(varMapCopy) result, err := varMap.ReplaceVars(raw) // New way (full expression support): env := expression.NewUnifiedEnv(varMapCopy) result, err := env.Interpolate(raw)
Example: "{{ url }}/api/{{ version }}/path" returns "google.com/api/v1/path"
type VarMapTracker ¶
type VarMapTracker struct {
VarMap VarMap
ReadVars map[string]string // stores variable key -> resolved value
}
VarMapTracker wraps a VarMap and tracks variable reads
func NewVarMapTracker ¶
func NewVarMapTracker(varMap VarMap) *VarMapTracker
NewVarMapTracker creates a new tracking wrapper around a VarMap
func (*VarMapTracker) Get ¶
func (vmt *VarMapTracker) Get(varKey string) (menv.Variable, bool)
Get tracks variable access and delegates to the underlying VarMap
func (*VarMapTracker) GetReadVars ¶
func (vmt *VarMapTracker) GetReadVars() map[string]string
GetReadVars returns a copy of all tracked variable reads
func (*VarMapTracker) ReplaceVars ¶
func (vmt *VarMapTracker) ReplaceVars(raw string) (string, error)
ReplaceVars tracks all variable reads during replacement and delegates to underlying VarMap.
LIMITATION: Same as VarMap.ReplaceVars() - only simple key lookup, no expressions.
RECOMMENDED: For full expression support with tracking, use expression.UnifiedEnv:
env := expression.NewUnifiedEnv(varMapCopy).WithTracking(tracker) result, err := env.Interpolate(raw)