This repository was archived by the owner on Mar 11, 2022. It is now read-only.
Add stricter error detection flags in bash scripts#151
Merged
seanmalloy merged 6 commits intoKohlsTechnology:masterfrom Nov 19, 2019
Merged
Add stricter error detection flags in bash scripts#151seanmalloy merged 6 commits intoKohlsTechnology:masterfrom
seanmalloy merged 6 commits intoKohlsTechnology:masterfrom
Conversation
mkyc
approved these changes
Nov 13, 2019
Contributor
|
@akavel looks good. Please resolve the merge conflict, and we can get this merged. |
added 6 commits
November 19, 2019 11:47
Add bash flags protecting against common errors in all scripts (in template-processors/ and in scripts/ too). Also add `set -x` where possible, to make potentially debugging them easier in future. As part of adding the flags, a place was found in discoverEnvironment.sh where `kubectl describe` command was failing. The place was marked with FIXME note and a separate issue will be opened for fixing it. Closes KohlsTechnology#74.
The `help set` command gives the following info about the `-u` flag: -u Treat unset variables as an error when substituting. Calling `set +u` *disables* this protection. This commit removes `set +u` in blocks where it appears to be spurious, as the variables used are actually expected to be set.
The blocks handling $TEMPLATE_GITCONFIG and $PARAMETER_GITCONFIG in gitClone.sh were broken in many ways. For starters, the blocks were never entered, as their entrance conditions were mutually opposing. This commit fixes obvious errors in those blocks to make the code run. Hopefully some tests will be added for this in the future.
Add quotes around environment variables, to improve script robustness.
Stylistic improvements.
e898d4e to
80bc935
Compare
Author
|
@seanmalloy rebased & resolved, PTAL |
seanmalloy
approved these changes
Nov 19, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
This PR adds error detection flags (
set -euo pipefail) in all bash scripts I was able to find in the repository, that were missing it before. This will improve robustness of the scripts.Adding those flags resulted in a failing command being found in
discoverEnvironment.sh. The PR adds a temporary workaround, and I opened a separate issue #152 with regards to fixing the underlying problem in the future.Additionally, the PR enables execution tracing (
set -x) in most of the scripts, including template-processors base scripts. This is intended to help when any debugging of the scripts is needed, and make it easier for contributors to provide better logs when reporting issues.Closes #74
Type of change