-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_json.sh
executable file
·71 lines (46 loc) · 1.23 KB
/
generate_json.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
#!/bin/bash
display_usage() {
echo
echo "Usage: $0"
echo
echo " -h, --help Display usage instructions"
echo " -e, --env prod,dev"
echo
}
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
# Initialize our own variables:
output_file=""
verbose=0
while getopts "h?me:" opt; do
case "$opt" in
h|\?)
display_usage
exit 0
;;
m) markdown=1
;;
e) environment=$OPTARG
;;
esac
done
shift $((OPTIND-1))
[ "${1:-}" = "--" ] && shift
echo "Creating output dir"
mkdir -p output/
echo "Processing Controls"
python cleanup_csv.py
#shorten the list a little bit
if [[ $environment == "dev" ]]; then
echo "Cutting records way back to avoid build times being really long"
cat output/fedramp_controls.json | jq '[limit(10;.[])]' > output/controls.json
echo "Created output/controls.json shortened dev version for use in explorer project"
rm -rf output/fedramp_controls.json
else
echo "Created output/controls.json for prod use in explorer project"
mv output/fedramp_controls.json output/controls.json
fi
if [[ $markdown == "1" ]]; then
echo "Generating fedramp_controls.markdown"
torsimany output/fedramp_controls.json
fi