fix(entrypoint): escape amp in sed#1300
Conversation
|
|
||
| # Substitute the kine datasource URL from the env var | ||
| sed -i "s {{ .KineDataSourceURLPlaceholder }} ${K0SMOTRON_KINE_DATASOURCE_URL} g" /etc/k0s/k0s.yaml | ||
| sed -i "s {{ .KineDataSourceURLPlaceholder }} ${K0SMOTRON_KINE_DATASOURCE_URL//&/\\&} g" /etc/k0s/k0s.yaml |
There was a problem hiding this comment.
Looks like it's not supported by posix shell, only in bash, that's why it fails on CI. We can switch it to
ESCAPED_K0SMOTRON_KINE_DATASOURCE_URL="$(printf '%s' "$K0SMOTRON_KINE_DATASOURCE_URL" | sed 's/&/\\&/g')"
sed -i "s {{ .KineDataSourceURLPlaceholder }} ${ESCAPED_K0SMOTRON_KINE_DATASOURCE_URL} g" /etc/k0s/k0s.yaml
There was a problem hiding this comment.
That one is correct, though the CI found the problem with POSIX-incompatible line, I am now trying to do this with an extra line
The comment is outdated, yes, the probllem is with POSIX
There was a problem hiding this comment.
Okay, seems the unit tests finally work 🎉
84a963f to
5b77c07
Compare
| # Substitute the kine datasource URL from the env var | ||
| sed -i "s {{ .KineDataSourceURLPlaceholder }} ${K0SMOTRON_KINE_DATASOURCE_URL} g" /etc/k0s/k0s.yaml | ||
| escaped_url=$(printf '%s' "$K0SMOTRON_KINE_DATASOURCE_URL" | sed 's/[&/\]/\\&/g') | ||
| sed -i "s|{{ .KineDataSourceURLPlaceholder }}|$escaped_url|g" /etc/k0s/k0s.yaml |
There was a problem hiding this comment.
Why do we switch the separator? I think | unlike space might be in the password.
There was a problem hiding this comment.
Initially it was a bit hard to debug the problem, so I decided to put it there. If spaces are okay in this context, let me revert it
Upd. Reverted
Escapes ampersand (&) symbol in the entrypoint.sh for the k0s, to avoid incorrect substitutions in case kine data source url has two or more options to connect. Fixes k0sproject#1299 Signed-off-by: Michael Morgen <mmorgen@posteo.com>
5b77c07 to
d18fc6b
Compare
Escapes ampersand (&) symbol in the entrypoint.sh for the k0s, to avoid incorrect substitutions in case kine data source url has two or more options to connect.
Fixes #1299