-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsam-wrapper.sh
executable file
·70 lines (57 loc) · 2.52 KB
/
sam-wrapper.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
70
#!/bin/bash
# Wrapper script which adds '--debug' to sam command as appropriate
set -eu
cmd="$1"
shift
function logger() {
local LOGFILE=~/.logs/sam-wrapper
if [ -f $LOGFILE ]; then
# echo "$(date) $0 $*" >> $LOGFILE
echo "$(date) $0 $@" >> $LOGFILE
fi
echo "$(date) $0 $*"
}
case "$cmd" in
--info)
# '--info' returns json parsed by some IDEs, outputing extra text will break Pycharm/sam
# as of 2021-06-04 I have: {"version": "1.23.0"}
exec /usr/local/bin/sam $cmd
;;
*)
# For 'local' commands, --debug flag must come after sub-command.
if [ "$cmd" == "local" ]; then
subcmd="$1"
shift
cmd="$cmd $subcmd"
fi
# redundant ? we log do it later?
logger " 0003 New sam command is:" /usr/local/bin/sam $cmd --debug "$@"
# echo "/usr/local/bin/sam $cmd --debug" "$@"
# : shift
;;
esac
# separate concern: python path / warning from
# echo ====================== Which python:
logger ====================== Which python: $(which python)
if false; then
echo ====================== with venv -
source ~/SYNC/dev-SHARED/pipenvs/bag_identifier/bin/activate
which python
python --version
fi
# quoting seems wrong --
# exec /usr/local/bin/sam $cmd --debug "$@"
# ->
# /Volumes/tk_cAsE/bin/sam-wrapper.sh local invoke S3EventFilterFunction --template /Volumes/tk_cAsE/git/S3EventFilterExecCommandLambda/.aws-sam/build/template.yaml --event "/private/var/folders/kz/73bxqchd1rsbxvyvc98dnmch0000gn/T/[Local] S3Event - x.not-bag-event.json" --debug-port 60006 --debugger-path /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev --debug-args "-u /tmp/lambci_debug_files/pydevd.py --multiprocess --port 60006 --file"
# New sam command is:
# /usr/local/bin/sam local invoke --debug "invoke S3EventFilterFunction --template /Volumes/tk_cAsE/git/S3EventFilterExecCommandLambda/.aws-sam/build/template.yaml --event /private/var/folders/kz/73bxqchd1rsbxvyvc98dnmch0000gn/T/[Local] S3Event - x.not-bag-event.json --debug-port 60006 --debugger-path /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev --debug-args -u /tmp/lambci_debug_files/pydevd.py --multiprocess --port 60006 --file"
function c_arg() { echo "$c: $*"; c=$((c+1)); }
# echo '============ just $@'
# c=1; for a in $@; do c_arg $a; done
# .. difference between $* $@ "$@" is hard ..
echo '============ arg breakdown - quoted: "$@"'
c=1; for a in "$@"; do c_arg $a; done
echo '====================== DOIT (exec): '
logger "exec /usr/local/bin/sam $cmd --debug $@"
exec /usr/local/bin/sam $cmd --debug "$@"
# fixed shift/subcmd --