Skip to content

Commit 871101f

Browse files
Scan utils
Signed-off-by: Lukasz Gryglicki <[email protected]>
1 parent 4bc8ac9 commit 871101f

File tree

6 files changed

+84
-2
lines changed

6 files changed

+84
-2
lines changed

utils/scan.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# STAGE=prod ./utils/scan.sh signatures signature_reference_id 29df5aa6-a396-4543-968c-f6e15f011d43
3+
if [ -z "$STAGE" ]
4+
then
5+
STAGE=dev
6+
fi
7+
if [ "$STAGE" = "dev" ]
8+
then
9+
schema='dynamodb_product_us_east1_dev'
10+
prefix='cla_dev_'
11+
fi
12+
if [ "$STAGE" = "prod" ]
13+
then
14+
schema='dynamodb_product_us_east_1'
15+
prefix='cla_prod_'
16+
fi
17+
if [ -z "$1" ]
18+
then
19+
echo "you need to specify table to query as a 1st parameter, for example 'signatures'"
20+
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"
21+
exit 1
22+
fi
23+
if [ -z "$2" ]
24+
then
25+
echo "$0: you need to specify '$1' table's column as a 2nd argument, see columns:"
26+
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"
27+
exit 2
28+
fi
29+
if [ -z "$3" ]
30+
then
31+
echo "$0: you need to specify '$1' table '$2' column value to search for"
32+
exit 3
33+
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'

utils/scan_companies.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
if [ -z "$STAGE" ]
3+
then
4+
STAGE=dev
5+
fi
6+
if [ -z "$1" ]
7+
then
8+
aws --profile lfproduct-${STAGE} dynamodb scan --table-name cla-${STAGE}-companies --max-items 100
9+
else
10+
aws --profile lfproduct-${STAGE} dynamodb scan --table-name cla-${STAGE}-companies --filter-expression "contains(${1},:v)" --expression-attribute-values "{\":v\":{\"S\":\"${2}\"}}" --max-items 100
11+
fi

utils/scan_events.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
if [ -z "$STAGE" ]
3+
then
4+
STAGE=dev
5+
fi
6+
if [ -z "$1" ]
7+
then
8+
aws --profile lfproduct-${STAGE} dynamodb scan --table-name cla-${STAGE}-events --max-items 100
9+
else
10+
aws --profile lfproduct-${STAGE} dynamodb scan --table-name cla-${STAGE}-events --filter-expression "contains(${1},:v)" --expression-attribute-values "{\":v\":{\"S\":\"${2}\"}}" --max-items 100
11+
fi

utils/scan_projects.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
#!/bin/bash
2-
aws --profile lfproduct-dev dynamodb scan --table-name cla-dev-projects --max-items 3
2+
if [ -z "$STAGE" ]
3+
then
4+
STAGE=dev
5+
fi
6+
if [ -z "$1" ]
7+
then
8+
aws --profile lfproduct-${STAGE} dynamodb scan --table-name cla-${STAGE}-projects --max-items 100
9+
else
10+
aws --profile lfproduct-${STAGE} dynamodb scan --table-name cla-${STAGE}-projects --filter-expression "contains(${1},:v)" --expression-attribute-values "{\":v\":{\"S\":\"${2}\"}}" --max-items 100
11+
fi

utils/scan_signatures.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ if [ -z "$STAGE" ]
44
then
55
STAGE=dev
66
fi
7-
aws --profile "lfproduct-${STAGE}" dynamodb scan --table-name "cla-${STAGE}-signatures" --max-items 100 | jq -r '.Items'
7+
if [ -z "$1" ]
8+
then
9+
aws --profile "lfproduct-${STAGE}" dynamodb scan --table-name "cla-${STAGE}-signatures" --max-items 100 | jq -r '.Items'
10+
else
11+
aws --profile "lfproduct-${STAGE}" dynamodb scan --table-name "cla-${STAGE}-signatures" --filter-expression "contains(${1},:v)" --expression-attribute-values "{\":v\":{\"S\":\"${2}\"}}" --max-items 100 | jq -r '.Items'
12+
fi

utils/scan_users.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# add: | jq -r '.[].signature_acl'
3+
if [ -z "$STAGE" ]
4+
then
5+
STAGE=dev
6+
fi
7+
if [ -z "$1" ]
8+
then
9+
aws --profile "lfproduct-${STAGE}" dynamodb scan --table-name "cla-${STAGE}-users" --max-items 100 | jq -r '.Items'
10+
else
11+
aws --profile "lfproduct-${STAGE}" dynamodb scan --table-name "cla-${STAGE}-users" --filter-expression "contains(${1},:v)" --expression-attribute-values "{\":v\":{\"S\":\"${2}\"}}" --max-items 100 | jq -r '.Items'
12+
fi

0 commit comments

Comments
 (0)