-
-
Notifications
You must be signed in to change notification settings - Fork 541
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
chore: Google Shell Style Compliance #326
Closed
mohitsaxenaknoldus
wants to merge
5
commits into
antonbabenko:master
from
mohitsaxenaknoldus:issue324
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,16 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" | |
# shellcheck source=_common.sh | ||
. "$SCRIPT_DIR/_common.sh" | ||
|
||
function main { | ||
####################################### | ||
# main function | ||
# Globals: | ||
# ARGS | ||
# HOOK_CONFIG | ||
# SCRIPT_DIR | ||
# Arguments: | ||
# None | ||
####################################### | ||
Comment on lines
+9
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too obvious. Not needed |
||
main() { | ||
common::initialize "$SCRIPT_DIR" | ||
common::parse_cmdline "$@" | ||
# shellcheck disable=SC2153 # False positive | ||
|
@@ -25,7 +34,7 @@ function main { | |
# Print out hook checks status (Passed/Failed), total monthly cost and | ||
# diff, summary about infracost check (non-supported resources etc.) | ||
####################################################################### | ||
function infracost_breakdown_ { | ||
infracost_breakdown_() { | ||
local -r hook_config="$1" | ||
local args | ||
read -r -a args <<< "$2" | ||
|
@@ -85,8 +94,8 @@ function infracost_breakdown_ { | |
real_value="$(jq "${jq_check[0]}" <<< "$RESULTS")" | ||
compare_value="${jq_check[1]}${jq_check[2]}" | ||
# Check types | ||
jq_check_type="$(jq -r "${jq_check[0]} | type" <<< "$RESULTS")" | ||
compare_value_type="$(jq -r "$compare_value | type" <<< "$RESULTS")" | ||
jq_check_type="$(jq -r "${jq_check[0]} | type" <<<"$RESULTS")" | ||
compare_value_type="$(jq -r "$compare_value | type" <<<"$RESULTS")" | ||
# Fail if comparing different types | ||
if [ "$jq_check_type" != "$compare_value_type" ]; then | ||
common::colorify "yellow" "Warning: Comparing values with different types may give incorrect result" | ||
|
@@ -127,12 +136,15 @@ function infracost_breakdown_ { | |
|
||
echo -e "\nSummary: $(jq -r '.summary' <<< "$RESULTS")" | ||
|
||
echo -e "\nTotal Monthly Cost: $(jq -r .totalMonthlyCost <<< "$RESULTS") $currency" | ||
echo "Total Monthly Cost (diff): $(jq -r .projects[].diff.totalMonthlyCost <<< "$RESULTS") $currency" | ||
echo -e "\nTotal Monthly Cost: $(jq -r .totalMonthlyCost <<<"$RESULTS") $currency" | ||
echo "Total Monthly Cost (diff): $(jq -r .projects[].diff.totalMonthlyCost <<<"$RESULTS") $currency" | ||
|
||
if $have_failed_checks; then | ||
exit 1 | ||
fi | ||
} | ||
|
||
|
||
|
||
|
||
[ "${BASH_SOURCE[0]}" != "$0" ] || main "$@" |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
The
name()
tofunction name
change was an effort by @MaxymVlasovPlease negotiate this with Max.
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.
Yeah, please return
function
word. Google style guide do not determine which syntax should be usedAbout
()
- not sure is it needed. It looks like apendix, during bash not be able to achievefunction function_name(var1, var2)
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.
Ah, George mentined that
()
will not works withinfunction
#326 (comment)