strip newline from all passed variables #613
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This prevents weird errors when attributes get shifted to newline and are executed by docker-entrypoint.sh. This PR removes the newline and when newline is stripped a 'Warning' is printed.
Short version:
docker-entrypoint.sh
scripts breaks (as seen later in examples of this PR) when 'newline' is present with rather ugly error that is hard to analyze without checking the code of script.Better error message or automated removal of 'newline' would be more desirable. This PR proposes automated 'newline' removal.
Long version:
I have run into this when trying to get image working with kubernetes and erroneously generated 'kubernetes secret' that contained the newline at the end. From looking at the logs the error that I have made required me to do debugging of image as there was no good message on what is going on. I believe there is no practical use case for having 'newline' in any of variables (if this is not true please correct me).
After the change proposed here the mysql image would progress with only printing warning when 'newline' is included which would make this work in most cases. With kubernetes the newline is preserved at the end of string which makes this invisible to user if such mistake is done.
Alternative approach to this would be to "hard fail" with error that 'newline' was encountered in some variable as that will most probably never be desired and user should be aware of it.
Main idea for creating this PR is to avoid unnecessary image debugging when 'newline' is accidentally included in any of the variables.
Please let me know what you think about this change and also let me know there are any changes needed for this to be merged. Thank you!
How to reproduce issue:
mysql:5.6
mysql:5.7
mysql:8.0
After fix the mysql can start properly and following can be seen in logs if there was any newline stripped (including the name of variable from which it was stripped so user can fix it):