Skip to content

Commit

Permalink
more fixes and improvementes
Browse files Browse the repository at this point in the history
  • Loading branch information
theflockers committed Jul 27, 2023
1 parent 7818bd8 commit 9354b0f
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,29 @@ spec:
git_clone_and_checkout --repository $REPO --revision $REVISION
for file in ${FILES}; do
# in case the file has comments, empty newlines and other special chages in the
# start of the file we need to know where the actual yaml data starts
blankLines=`awk '/[[:alpha:]]+/{ if(! match($0, "^#")) { print NR-1; exit } }' $file`
jq -cr ".paths[] | select(.path==\"${file}\") | .replacements[] | [.key, .replacement] | join(\"\t\")" $TEMP| \
while read replacement; do
IFS=$'\t' read KEY REPLACE <<< $replacement
# the key position
# getting the key's position
echo -en "Searching for key \`${KEY}\`: "
LN=`yq "${KEY} | line" $file`
if [ "${LN}" == 0 ]; then
foundAt=`yq "${KEY} | line" $file`
if [ "${foundAt}" -eq 0 ]; then
echo "NOT FOUND"
continue
fi
echo "FOUND"
# yq always gives the pos -1 line, so we add it
LINES=$(expr `yq "${KEY}" $file |wc -l` + 1)
# getting the value size (in number of lines)
valueSize=$(expr `yq "${KEY}" $file |wc -l`)
startBlock=`expr $foundAt + $blankLines`
# run the replace
sed -i "${LN},+${LINES}s${REPLACE}" $file
sed -i "${startBlock},+${valueSize}s${REPLACE}" $file
done
done
Expand Down

0 comments on commit 9354b0f

Please sign in to comment.