https://github.com/koalaman/shellcheck/wiki/SC2251
This may be masking some test failures.
We have a bunch of test code like this:
set -o errexit
[...]
! kubectl get pod wrong-pod
[...]
This test will succeed no matter what the result (return code) of kubectl is.
Changelog:
https://github.com/koalaman/shellcheck/blob/master/CHANGELOG.md
We have some new erros due to the version bump.
- SC2034: VARIABLE_XYZ appears unused. Verify use (or export if used externally).
- Applies to all scripts we source in other scripts
- SC2039: In POSIX sh, set option pipefail is undefined.
- Applies to files using it with "sh" instead of "bash" in the shebang
- SC2054: Use spaces, not commas, to separate array elements.
- Fixing Should make no difference in the code
- SC2128: Expanding an array without an index only gives the first element.
- Fixing Should make no difference in the code
- SC2251: This ! is not on a condition and skips errexit. Use `&& exit 1` instead, or make sure $? is checked.
- Not 100% sure if we can swap to `&& exit 1`. Applies to a lot of
test code.
All changes should be straight forward to fix, but will be done in a
separate PR.
The bug seems to be currently dormant but I managed to trigger it in
some manual tests.
When the bug is triggered it appends empty --prune-whitelist without any
value which in turn can capture the next flag and can cause addon
manager to fail.
E.g. when bug is not triggered the kubectl command looks like this
```
kubectl ... --prune-whitelist extensions/v1beta1/Ingress --recursive ...
```
When it's triggered it will be
```
kubectl ... --prune-whitelist --recursive ...
```
which will capture the --recursive flag and will make addon-manager to
fail as there are no yamls in the top directory.
Clean up useless functions, only keep the basic function Deal
and the function DealIntoHand which will be used by Priority
and Fairness.
Improve some comments for constants and functions.
Introduce Dealer to combine parameters and methods into a whole.
Use fixed-size slice to improve performance.
Use math.Ceil and math.Log2 to calculate required entropy bits.
Make the given hand adaptive to handSize in DealIntoHand.
Signed-off-by: Bruce Ma <brucema19901024@gmail.com>