-
Notifications
You must be signed in to change notification settings - Fork 67
fix(entrypoint): escape amp in sed #1300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we switch the separator? I think | unlike space might be in the password.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
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