-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
133 additions
and
163 deletions.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
function findAllTerraformDirs() { | ||
local ignores="" | ||
local hide_root=false | ||
local format="json" | ||
local args=("$@") | ||
|
||
# Parse arguments | ||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
--ignores) | ||
shift | ||
while [[ $# -gt 0 && $1 != --* ]]; do | ||
ignores="$ignores -o -name '$1'" | ||
shift | ||
done | ||
;; | ||
--hide-root) | ||
hide_root=true | ||
shift | ||
;; | ||
--format) | ||
shift | ||
format=$1 | ||
shift | ||
;; | ||
*) | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
|
||
find_command="find . -type d \( -name '.terraform*' -o -name 'deprecated*' $ignores \) -prune -o \ | ||
-name '*.tf' \ | ||
-not -path '*/.terraform/*' \ | ||
-exec dirname {} \; | \ | ||
sort | \ | ||
uniq" | ||
|
||
|
||
if [ "$format" = "json" ]; then | ||
jq_filter='split("\n") | map(select(. != ""))' | ||
if [ "$hide_root" = true ]; then | ||
jq_filter='split("\n") | map(select(. != "" and . != "."))' | ||
fi | ||
find_command="$find_command | jq --raw-input --slurp '$jq_filter'" | ||
elif [ "$format" = "plain" ]; then | ||
if [ "$hide_root" = true ]; then | ||
find_command="$find_command | grep -v '^\\.$'" | ||
fi | ||
fi | ||
|
||
eval $find_command | ||
} | ||
|
||
findLambdaFunctions() { | ||
# lambdas are located in lambdas/functions | ||
# only the first level director should be resulted | ||
# output format plain or json, json is default, not other options needed | ||
|
||
local format="json" | ||
local args=("$@") | ||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
--format) | ||
shift | ||
format=$1 | ||
shift | ||
;; | ||
*) | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
find_command="find lambdas/functions -maxdepth 1 -type d | \ | ||
sort | \ | ||
uniq" | ||
|
||
if [ "$format" = "json" ]; then | ||
jq_filter='split("\n") | map(select(. != ""))' | ||
find_command="$find_command | jq --raw-input --slurp '$jq_filter'" | ||
fi | ||
|
||
eval $find_command | ||
} |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#source "$(dirname "${BASH_SOURCE[0]}")/find.sh" | ||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/find.sh" | ||
|
||
generateDummyLambdaZip() { | ||
lambdaDirs=($(findLambdaFunctions --format plain)) | ||
echo ${lambdaDirs[@]} | ||
echo ---- | ||
for lambdaDir in "${lambdaDirs[@]}"; do | ||
echo Generating dummy zip for $lambdaDir/$(basename $lambdaDir).zip | ||
touch "$lambdaDir/$(basename $lambdaDir).zip" | ||
done | ||
} |