-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* replace sed with heredoc * add dry_run to log-vars
- Loading branch information
Showing
6 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
### | ||
# basic tempalate variable replacement using heredoc | ||
# runs on a .tpl. file in form some_file.tpl.yml for example | ||
# replaces variables with values | ||
# | ||
# $1 - the tpl.yml file | ||
# $2 - the output dir to put the processed files with the .tpl. stripped from the name | ||
# | ||
# @stdout the processed tpl build file name | ||
# | ||
function heredoc_tpl { | ||
mkdir -p "$2" | ||
# parse just the file name | ||
local tplFile=${1##*/} | ||
# replace .tpl.yml with .yml or .tpl.any with .any is what `/.tpl./.` is doing | ||
local processedTpl="$2/${tplFile/.tpl./.}" | ||
|
||
## LEAVE THIS INDENT, heredoc needs to to look this way | ||
eval "cat << EOF | ||
$(<"$1") | ||
EOF | ||
" > "$processedTpl" | ||
|
||
echo "$processedTpl" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters