Skip to content

Commit

Permalink
Fixed script for special chars
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingface0 committed Sep 1, 2023
1 parent fe0f464 commit af61eb7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion k8_encrypt_secret.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ for i in $(awk '/^[^ ]/{ f=/^data:/; next } f{ if (match($0, /^\s+[a-zA-Z0-9_]+\
# Set base64's wrap to zero to have it all in one line.
# Use commas in the sed regexp, as we may have '/' in the values (e.g. CMSWEB_FRONTEND_PROXY_URL).
# Leading spaces are not preserved in the replacement string, so we're adding them manually.
sed -r "s,^$i$, $(echo $i | awk '{print $1}') $(echo $i | awk '{printf $2}' | base64 --wrap 0) # $(echo $i | awk '{printf $2}'),g" -i $OUT_FILE
i_escaped=$(echo $i | awk '{ gsub(/\\/, "\\\\"); gsub(/\^/, "\\^"); gsub(/\(/, "\\("); gsub(/\//, "\\/"); printf $0 }')
sed_expr="s,^$i_escaped$, $(echo $i | awk '{print $1}') $(echo $i | awk '{printf $2}' | base64 --wrap 0),g"
sed -E $sed_expr -i $OUT_FILE
done

0 comments on commit af61eb7

Please sign in to comment.