Documentation ¶
Index ¶
- Variables
- func ErrIllegalSecretCharacter(lineNo, colNo int, char rune) error
- func ErrIllegalVariableCharacter(lineNo, colNo int, char rune) error
- func ErrSecretTagNotClosed(lineNo, colNo int) error
- func ErrUnexpectedCharacter(lineNo, colNo int, actual, expected rune) error
- func ErrVariableTagNotClosed(lineNo, colNo int) error
- func IsV1Template(raw []byte) bool
- type Parser
- type SecretReader
- type Template
- type VariableReader
Constants ¶
This section is empty.
Variables ¶
var (
ErrTemplateVarNotFound = tplError.Code("template_var_not_found").ErrorPref("no value was supplied for template variable '%s'")
)
Evaluate errors
Functions ¶
func ErrIllegalSecretCharacter ¶
ErrIllegalSecretCharacter is returned when a secret tag contains a character that is not allowed.
func ErrIllegalVariableCharacter ¶
ErrIllegalVariableCharacter is returned when a variable tag contains a character that is not allowed.
func ErrSecretTagNotClosed ¶
ErrSecretTagNotClosed is returned when a secret tag is opened, but never closed.
func ErrUnexpectedCharacter ¶
ErrUnexpectedCharacter is returned when expecting a specific character, for example the first character of a closing delimiter after a space occurred in a tag, or the second character of a closing delimiter after the first character of the closing delimiter.
func ErrVariableTagNotClosed ¶
ErrVariableTagNotClosed is returned when a variable tag is opened, but never closed.
func IsV1Template ¶ added in v0.24.1
IsV1Template returns whether v1 secret tags are used in the given raw bytes.
Types ¶
type Parser ¶
Parser parses a raw string to a template.
func NewV1Parser ¶
func NewV1Parser() Parser
NewV1Parser returns a parser for the v1 template syntax.
V1 templates can contain secret paths between ${}: ${ path/to/secret }
V1 templates do not support template variables.
func NewV2Parser ¶
func NewV2Parser() Parser
NewV2Parser returns a parser for the v2 template syntax.
V2 templates can contain secret paths between brackets: {{ path/to/secret }}
Within secret paths, variables can be used. Variables are given between `${` and `}`. For example: {{ ${app}/db/secret }} Variables cannot be used outside of secret paths.
Spaces directly after opening delimiters (`{{` and `${`) and directly before closing delimiters (`}}`, `}`) are ignored. They are not included in the secret pahts and variable names.
type SecretReader ¶
SecretReader fetches a secret by its path.
type Template ¶
type Template interface { // Evaluate renders a template. It replaces all variable- and secret tags in the template. // The supplied variables should have lowercase keys. Evaluate(varReader VariableReader, sr SecretReader) (string, error) ContainsSecrets() bool }
Template contains secret and variable references. It can be evaluated to resolve to a string.
type VariableReader ¶ added in v0.34.0
VariableReader fetches a template variable by its name.