Skip to content

Commit

Permalink
utils: add substituteStr
Browse files Browse the repository at this point in the history
This will be used by the pipeline to process some of the templated
fields in `config.yaml`. Putting it here allows us to work around the
fact that the `SimpleTemplateEngine` API would normally have to be
allowed by an administrator first.
  • Loading branch information
jlebon committed Oct 13, 2022
1 parent 574fbc6 commit fdcf3ee
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions vars/utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ def getCosaDir(params = [:]) {
def pathExists(path) {
return shwrapRc("test -e ${path}") == 0
}

// Thin wrapper around SimpleTemplateEngine().
// tmpl_str string -- templated string
// bindings map -- variables to fill in
def substituteStr(tmpl_str, bindings) {
def engine = new groovy.text.SimpleTemplateEngine()
def tmpl = engine.createTemplate(tmpl_str).make(bindings)
return tmpl.toString()
}

0 comments on commit fdcf3ee

Please sign in to comment.