Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr 384 #505

Merged
merged 4 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/goss/goss-shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down