Documentation ¶
Index ¶
- Variables
- func EscapeSpecialCharacters(properties map[string]interface{}) (map[string]interface{}, error)
- func EscapeSpecialCharactersInValue(value interface{}, escapeFunc StringEscapeFunction) (interface{}, error)
- func UnmarshalYaml(text string, fileName string) (map[string]map[string]string, error)
- func UnmarshalYamlWithoutTemplating(text string, fileName string) (map[string]map[string]string, error)
- type StringEscapeFunction
- type Template
- type UnmarshalYamlFunc
Constants ¶
This section is empty.
Variables ¶
var FullStringEscapeFunction = escapeCharactersForJson
FullStringEscapeFunction fully escapes any special characters in the input string, ensure it is valid for use in JSON
var SimpleStringEscapeFunction = escapeSimpleCharacters
SimpleStringEscapeFunction only escapes newline characters in an input string
Functions ¶
func EscapeSpecialCharacters ¶
EscapeSpecialCharacters takes a map of config properties (some level of map (of maps...) of string) and escapes any newline characters in it Note: this is in use in both v1 config templating
func EscapeSpecialCharactersInValue ¶
func EscapeSpecialCharactersInValue(value interface{}, escapeFunc StringEscapeFunction) (interface{}, error)
EscapeSpecialCharactersInValue takes a value and tries to escape any strings in it - it will walk recursively in case of maps/maps-of-maps of string and escape any special characters using a StringEscapeFunction. This is used by v1 config templating - with a simple function escaping newlines and v2 parameter values returns - with an escape function escaping strings to be fully JSON compliant
func UnmarshalYaml ¶
UnmarshalYaml takes the contents of a yaml file and converts it to a map[string]map[string]string. The file be templated, with any references replaced - or resulting in an error if no value is available.
The yaml file should have the following format:
some-name-1:
- list-key-1: "list-entry-1"
- list-key-2: "list-entry-2"
some-name-2:
- list-key-1: "list-entry-1"
func UnmarshalYamlWithoutTemplating ¶
func UnmarshalYamlWithoutTemplating(text string, fileName string) (map[string]map[string]string, error)
UnmarshalYamlWithoutTemplating takes the contents of a yaml file and converts it to a map[string]map[string]string. If references should be replaced (which you generally want) use UnmarshalYaml instead.
Types ¶
type StringEscapeFunction ¶
type Template ¶
Template wraps the underlying templating logic and provides a means of setting config values just on one place. It is intended to be language-agnostic, the file type does not matter (yaml, json, ...)
func NewTemplate ¶
NewTemplate creates a new template for the given file