-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add script to debug gRPC endpoints
Signed-off-by: Artur Troian <[email protected]>
- Loading branch information
Showing
1 changed file
with
97 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
|
||
akash_api=$(realpath "$SCRIPT_DIR/../") | ||
|
||
if [ ! -d "${akash_api}/vendor" ]; then | ||
echo "for script to work run \"make modvendor\"" | ||
exit 1 | ||
fi | ||
|
||
short_opts=h | ||
long_opts=help/host:/mode: # those who take an arg END with : | ||
|
||
host=localhost:8081 | ||
mode= | ||
|
||
while getopts ":$short_opts-:" o; do | ||
case $o in | ||
:) | ||
echo >&2 "option -$OPTARG needs an argument" | ||
continue | ||
;; | ||
'?') | ||
echo >&2 "bad option -$OPTARG" | ||
continue | ||
;; | ||
-) | ||
o=${OPTARG%%=*} | ||
OPTARG=${OPTARG#"$o"} | ||
lo=/$long_opts/ | ||
case $lo in | ||
*"/$o"[!/:]*"/$o"[!/:]*) | ||
echo >&2 "ambiguous option --$o" | ||
continue | ||
;; | ||
*"/$o"[:/]*) | ||
;; | ||
*) | ||
o=$o${lo#*"/$o"}; | ||
o=${o%%[/:]*} | ||
;; | ||
esac | ||
|
||
case $lo in | ||
*"/$o/"*) | ||
OPTARG= | ||
;; | ||
*"/$o:/"*) | ||
case $OPTARG in | ||
'='*) | ||
OPTARG=${OPTARG#=} | ||
;; | ||
*) | ||
eval "OPTARG=\$$OPTIND" | ||
if [ "$OPTIND" -le "$#" ] && [ "$OPTARG" != -- ]; then | ||
OPTIND=$((OPTIND + 1)) | ||
else | ||
echo >&2 "option --$o needs an argument" | ||
continue | ||
fi | ||
;; | ||
esac | ||
;; | ||
*) echo >&2 "unknown option --$o"; continue;; | ||
esac | ||
esac | ||
case "$o" in | ||
host) | ||
host=$OPTARG | ||
;; | ||
mode) | ||
case "$OPTARG" in | ||
plaintext|insecure) | ||
;; | ||
*) | ||
echo >&2 "option --$o can be plaintext|insecure" | ||
;; | ||
esac | ||
|
||
mode=-$OPTARG | ||
;; | ||
esac | ||
done | ||
shift "$((OPTIND - 1))" | ||
|
||
grpcurl \ | ||
"$mode" \ | ||
-use-reflection \ | ||
-proto="${akash_api}/proto/provider/akash/inventory/v1/service.proto" \ | ||
-proto="${akash_api}/proto/provider/akash/provider/v1/service.proto" \ | ||
-import-path="${akash_api}/proto/provider" \ | ||
-import-path="${akash_api}/proto/node" \ | ||
-import-path="${akash_api}/vendor/github.com/cosmos/cosmos-sdk/third_party/proto" \ | ||
-import-path="${akash_api}/vendor" \ | ||
"$host" \ | ||
"$@" |