Documentation ¶
Index ¶
- Variables
- func DefaultReplacementAppliedFunc(substring string, mapping Mapping, cfg *Config) (string, bool, error)
- func DefaultReplacementFunc(substring string, mapping Mapping, cfg *Config) (string, error)
- func ExtractVariables(configDict map[string]interface{}, pattern *regexp.Regexp) map[string]Variable
- func Substitute(template string, mapping Mapping) (string, error)
- func SubstituteWith(template string, mapping Mapping, pattern *regexp.Regexp, ...) (string, error)
- func SubstituteWithOptions(template string, mapping Mapping, options ...Option) (string, error)
- func WithoutLogging(cfg *Config)
- type Config
- type InvalidTemplateError
- type Mapping
- type MissingRequiredError
- type Option
- type ReplacementFunc
- type SubstituteFunc
- type Variable
Constants ¶
This section is empty.
Variables ¶
var DefaultPattern = regexp.MustCompile(patternString)
Functions ¶
func DefaultReplacementFunc ¶
func ExtractVariables ¶
func ExtractVariables(configDict map[string]interface{}, pattern *regexp.Regexp) map[string]Variable
ExtractVariables returns a map of all the variables defined in the specified compose file (dict representation) and their default value if any.
func Substitute ¶
Substitute variables in the string with their values
func SubstituteWith ¶
func SubstituteWith(template string, mapping Mapping, pattern *regexp.Regexp, subsFuncs ...SubstituteFunc) (string, error)
SubstituteWith substitute variables in the string with their values. It accepts additional substitute function.
func SubstituteWithOptions ¶
SubstituteWithOptions substitute variables in the string with their values. It accepts additional options such as a custom function or pattern.
func WithoutLogging ¶
func WithoutLogging(cfg *Config)
Types ¶
type InvalidTemplateError ¶
type InvalidTemplateError struct {
Template string
}
InvalidTemplateError is returned when a variable template is not in a valid format
func (InvalidTemplateError) Error ¶
func (e InvalidTemplateError) Error() string
type Mapping ¶
Mapping is a user-supplied function which maps from variable names to values. Returns the value as a string and a bool indicating whether the value is present, to distinguish between an empty string and the absence of a value.
type MissingRequiredError ¶
MissingRequiredError is returned when a variable template is missing
func (MissingRequiredError) Error ¶
func (e MissingRequiredError) Error() string
type Option ¶
type Option func(*Config)
func WithPattern ¶
func WithReplacementFunction ¶
func WithReplacementFunction(replacementFunc ReplacementFunc) Option
func WithSubstitutionFunction ¶
func WithSubstitutionFunction(subsFunc SubstituteFunc) Option
type ReplacementFunc ¶
ReplacementFunc is a user-supplied function that is apply to the matching substring. Returns the value as a string and an error.
type SubstituteFunc ¶
SubstituteFunc is a user-supplied function that apply substitution. Returns the value as a string, a bool indicating if the function could apply the substitution and an error.