Skip to content

Commit 7421f98

Browse files
Utils for scanning gerrit instances and requesting gerrit agreements
Signed-off-by: Lukasz Gryglicki <[email protected]>
1 parent 3f87d9d commit 7421f98

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

utils/gerrit_agreement.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# API_URL=https://[xyz].ngrok-free.app (defaults to localhost:5000)
3+
# API_URL=https://api.dev.lfcla.com
4+
# https://api.dev.lfcla.com/v2/gerrit/01af041c-fa69-4052-a23c-fb8c1d3bef24/corporate/agreementUrl.html
5+
6+
if [ -z "$1" ]
7+
then
8+
echo "$0: you need to specify agreement type: corporate|individual"
9+
exit 1
10+
fi
11+
export agreement_type="$1"
12+
13+
if [ -z "$2" ]
14+
then
15+
echo "$0: you need to specify gerrit instance id as a 1st parameter, example '01af041c-fa69-4052-a23c-fb8c1d3bef24'"
16+
exit 1
17+
fi
18+
export gerrit_id="$2"
19+
20+
if [ -z "$API_URL" ]
21+
then
22+
export API_URL="http://localhost:5000"
23+
fi
24+
25+
API="${API_URL}/v2/gerrit/${gerrit_id}/${agreement_type}/agreementUrl.html"
26+
27+
if [ ! -z "$DEBUG" ]
28+
then
29+
echo "curl -s -XGET -H \"Content-Type: application/json\" \"${API}\""
30+
curl -s -XGET -H "Content-Type: application/json" "${API}"
31+
else
32+
curl -s -XGET -H "Content-Type: application/json" "${API}" | jq -r '.'
33+
fi

utils/scan.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22
# STAGE=prod ./utils/scan.sh signatures signature_reference_id 29df5aa6-a396-4543-968c-f6e15f011d43
3+
# ALL=1
4+
# DEBUG=1 ALL=1 ./utils/scan.sh gerrit-instances
35
if [ -z "$STAGE" ]
46
then
57
STAGE=dev
@@ -20,15 +22,20 @@ then
2022
echo "possible tables include: approvals, ccla_whitelist_requests, cla_manager_requests, companies, company_invites, events, gerrit_instances, github_orgs, gitlab_orgs, metrics, projects, projects_cla_groups, repositories, session_store, signatures, store, user_permissions, users"
2123
exit 1
2224
fi
23-
if [ -z "$2" ]
25+
if ( [ -z "$2" ] && [ -z "$ALL" ] )
2426
then
2527
echo "$0: you need to specify '$1' table's column as a 2nd argument, see columns:"
2628
snowsql $(cat ./snowflake.secret) -o friendly=false -o header=true -o timing=false -o output_format=plain -q "select * from fivetran_ingest.${schema}.${prefix}${1} limit 1"
2729
exit 2
2830
fi
29-
if [ -z "$3" ]
31+
if ( [ -z "$3" ] && [ -z "$ALL" ] )
3032
then
3133
echo "$0: you need to specify '$1' table '$2' column value to search for"
3234
exit 3
3335
fi
34-
aws --profile "lfproduct-${STAGE}" dynamodb scan --table-name "cla-${STAGE}-${1}" --filter-expression "contains(${2},:v)" --expression-attribute-values "{\":v\":{\"S\":\"${3}\"}}" --max-items 100 | jq -r '.Items'
36+
if ( [ -z "$2" ] || [ -z "$3" ] )
37+
then
38+
aws --profile "lfproduct-${STAGE}" dynamodb scan --table-name "cla-${STAGE}-${1}" --max-items 100 | jq -r '.Items'
39+
else
40+
aws --profile "lfproduct-${STAGE}" dynamodb scan --table-name "cla-${STAGE}-${1}" --filter-expression "contains(${2},:v)" --expression-attribute-values "{\":v\":{\"S\":\"${3}\"}}" --max-items 100 | jq -r '.Items'
41+
fi

0 commit comments

Comments
 (0)