vars

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package vars provides shared regex patterns and utilities for variable expansion.

Index

Constants

This section is empty.

Variables

View Source
var ChainVar = regexp.MustCompile(`\$\{[^}]*\.[^}]+\}`)

ChainVar matches ${step.field} patterns (contains a dot).

View Source
var EnvOnly = regexp.MustCompile(`\$\{([A-Za-z_][A-Za-z0-9_]*)\}`)

EnvOnly matches ${VAR} patterns without dots (environment variables only). Group 1: contents inside ${...}

View Source
var Expansion = regexp.MustCompile(`\$\{([^}]+)\}`)

Expansion matches ${VAR} patterns only (strict form required). This prevents ambiguity with dollar signs in bcrypt hashes, dollar amounts, etc. Variables can contain dots for chain references: ${step.field} Group 1: contents inside ${...}

Functions

func EnvResolver added in v0.5.0

func EnvResolver(key string) (string, error)

EnvResolver resolves environment variables only.

func ExpandAll added in v0.5.0

func ExpandAll(obj any, resolver Resolver)

ExpandAll recursively expands environment variables in all string fields and map values of a struct using the provided resolver. This eliminates the need for manual field-by-field expansion when adding new config fields.

func ExpandString

func ExpandString(input string, resolver Resolver) (string, error)

ExpandString replaces all ${VAR} occurrences in input using the resolver.

func HasChainVars

func HasChainVars(s string) bool

HasChainVars returns true if the string contains chain variable references (${step.field}).

func HasEnvVars

func HasEnvVars(s string) bool

HasEnvVars returns true if the string contains environment variable references ($VAR or ${VAR}).

func MockResolver added in v0.5.0

func MockResolver(key string) (string, error)

MockResolver provides placeholder values for variable interpolation in LSP validation. This allows the compiler to validate the config structure even without real env vars.

Types

type Resolver

type Resolver func(key string) (string, error)

Resolver resolves a variable key to its value.

Jump to

Keyboard shortcuts

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