Skip to content
Permalink
Browse files

Pr 384 (#505)

* Add ToUpper and ToLower to Template funcMap

Add basic ToUpper and ToLower support for Template pipelines.

* Add integration test

* Add ToLower/ToUpper documentation

* Make casing consistent on new template functions
  • Loading branch information
aelsabbahy committed Nov 25, 2019
1 parent 282afa8 commit 777ae41a0bea7f5791a2f2da581434a86ffe1895
Showing with 6 additions and 2 deletions.
  1. +2 −0 docs/manual.md
  2. +2 −2 integration-tests/goss/goss-shared.yaml
  3. +2 −0 template.go
@@ -870,6 +870,8 @@ Available functions beyond text/template [built-in functions](https://golang.org
* `readFile "fileName"` - Reads file content into a string, trims whitespace. Useful when a file contains a token.
* **NOTE:** Goss will error out during during the parsing phase if the file does not exist, no tests will be executed.
* `regexMatch "(some)?reg[eE]xp"` - Tests the piped input against the regular expression argument.
* `toLower` - Changes piped input to lowercase
* `toUpper` - Changes piped input to UPPERCASE
**NOTE:** gossfiles containing text/template `{{}}` controls will no longer work with `goss add/autoadd`. One way to get around this is to split your template and static goss files and use [gossfile](#gossfile) to import.
@@ -18,8 +18,8 @@ command:
exit-status: 0
skip: true
file:
{{range mkSlice "/etc/passwd" "/etc/group"}}
{{.}}:
{{range mkSlice "/etc/PAsswD" "/etc/group"}}
{{. | toLower}}:
exists: true
mode: '0644'
owner: root
@@ -47,6 +47,8 @@ var funcMap = map[string]interface{}{
"readFile": readFile,
"getEnv": getEnv,
"regexMatch": regexMatch,
"toUpper": strings.ToUpper,
"toLower": strings.ToLower,
}

func NewTemplateFilter(varsFile string) func([]byte) []byte {

0 comments on commit 777ae41

Please sign in to comment.
You can’t perform that action at this time.