template

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractVariables

func ExtractVariables(configDict any) 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

func Substitute(template string, resolver Resolver) (string, error, error)

SubstituteWithOptions substitute variables in the string with their values. It accepts additional options such as a custom function or pattern.

Types

type EnvironmentHelper added in v0.9.0

type EnvironmentHelper struct {
	// contains filtered or unexported fields
}

func (EnvironmentHelper) Each added in v0.9.0

func (l EnvironmentHelper) Each(cb func(name string, vr expand.Variable) bool)

func (EnvironmentHelper) Get added in v0.9.0

func (helper EnvironmentHelper) Get(name string) expand.Variable

type InvalidTemplateError

type InvalidTemplateError struct {
	Template string
	Wrapped  error
}

InvalidTemplateError is returned when a variable template is not in a valid format

func (InvalidTemplateError) Error

func (e InvalidTemplateError) Error() string

type MissingRequiredError

type MissingRequiredError struct {
	Variable string
	Reason   string
}

MissingRequiredError is returned when a variable template is missing

func (MissingRequiredError) Error

func (e MissingRequiredError) Error() string

type Resolver added in v0.9.0

type Resolver func(string) (string, bool)

Resolver 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 Variable

type Variable struct {
	Name          string
	DefaultValue  string
	PresenceValue string
	Required      bool
}

Jump to

Keyboard shortcuts

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