-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjunk.sh
69 lines (54 loc) · 2.09 KB
/
junk.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
if [ "${AWS_PROVIDER_PATH}" = "" ]; then
echo "ERROR: Must set the AWS_PROVIDER_PATH to AWS provider location"
fi
rm ./results/*txt || echo "Nothing to delete"
mkdir results || echo "Results directory already exists"
tests=( ${AWS_PROVIDER_PATH}/awsproviderlint/passes/AWS*/ )
for test_path in ${tests[@]}; do
test=$(basename ${test_path})
echo "Static check: ${test}"
descriptions+=( "awsproviderlint! [${test}](https://github.com/terraform-providers/terraform-provider-aws/tree/master/awsproviderlint/passes/${test})" )
filenames+=( "./results/${test}.txt" )
awsproviderlint -${test} ${AWS_PROVIDER_PATH}/aws &> ${filenames[${#filenames[@]}-1]}
done
tests=( ${TF_PROVIDER_LINT_PATH}/passes/{AT*,R*,S*,V*}/ )
for test_path in ${tests[@]}; do
test=$(basename ${test_path})
echo "Static check: ${test}"
descriptions+=( "tfproviderlint! [${test}](https://github.com/bflad/tfproviderlint/tree/master/passes/${test})" )
filenames+=( "./results/${test}.txt" )
awsproviderlint -${test} ${AWS_PROVIDER_PATH}/aws &> ${filenames[${#filenames[@]}-1]}
done
###################
# get tallies #
###################
talliesFile="./results/tallies.txt"
printf "Tallies\n" > ${talliesFile}
for i in "${!descriptions[@]}"; do
count=$(< "${filenames[$i]}" wc -l)
printf "%s\t%s\n" "$count" "${descriptions[$i]}" >> ${talliesFile}
done
###################
# create readme #
###################
readmeFile="README.md"
cat README_header.md > ${readmeFile}
printf "# %s\n" "Checks" >> ${readmeFile}
lastTitle=""
for i in "${!descriptions[@]}"; do
IFS='!'
read -ra titleDesc <<< "${descriptions[$i]}"
title="${titleDesc[0]}"
description="${titleDesc[1]}"
if [ "${title}" != "${lastTitle}" ]; then
printf "## %s\n\n" "${title}" >> ${readmeFile}
lastTitle="${title}"
fi
count=$(< "${filenames[$i]}" wc -l)
example=$(shuf -n 1 "${filenames[$i]}")
printf "### %s\nCount: %s\n" "${description}" "${count}" >> ${readmeFile}
if (( count > 0 )); then
printf "[List matches](%s)\n\n" "${filenames[$i]}" >> ${readmeFile}
printf "Example: \`%s\`\n\n" "${example}" >> ${readmeFile}
fi
done