Documentation ¶
Index ¶
- 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 ¶
This section is empty.
Functions ¶
func DefaultReplacementAppliedFunc ¶ added in v1.16.0
func DefaultReplacementFunc ¶ added in v1.15.0
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 composefile (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 ¶ added in v1.15.0
SubstituteWithOptions substitute variables in the string with their values. It accepts additional options such as a custom function or pattern.
func WithoutLogging ¶ added in v1.15.0
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 ¶ added in v1.13.4
MissingRequiredError is returned when a variable template is missing
func (MissingRequiredError) Error ¶ added in v1.13.4
func (e MissingRequiredError) Error() string
type Option ¶ added in v1.15.0
type Option func(*Config)
func WithPattern ¶ added in v1.15.0
func WithReplacementFunction ¶ added in v1.15.0
func WithReplacementFunction(replacementFunc ReplacementFunc) Option
func WithSubstitutionFunction ¶ added in v1.15.0
func WithSubstitutionFunction(subsFunc SubstituteFunc) Option
type ReplacementFunc ¶ added in v1.15.0
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.