Skip to content

Commit

Permalink
Scan utils
Browse files Browse the repository at this point in the history
Signed-off-by: Lukasz Gryglicki <[email protected]>
  • Loading branch information
lukaszgryglicki committed Feb 11, 2025
1 parent 4bc8ac9 commit 871101f
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 2 deletions.
34 changes: 34 additions & 0 deletions utils/scan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# STAGE=prod ./utils/scan.sh signatures signature_reference_id 29df5aa6-a396-4543-968c-f6e15f011d43
if [ -z "$STAGE" ]
then
STAGE=dev
fi
if [ "$STAGE" = "dev" ]
then
schema='dynamodb_product_us_east1_dev'
prefix='cla_dev_'
fi
if [ "$STAGE" = "prod" ]
then
schema='dynamodb_product_us_east_1'
prefix='cla_prod_'
fi
if [ -z "$1" ]
then
echo "you need to specify table to query as a 1st parameter, for example 'signatures'"
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"
exit 1
fi
if [ -z "$2" ]
then
echo "$0: you need to specify '$1' table's column as a 2nd argument, see columns:"
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"
exit 2
fi
if [ -z "$3" ]
then
echo "$0: you need to specify '$1' table '$2' column value to search for"
exit 3
fi
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'
11 changes: 11 additions & 0 deletions utils/scan_companies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
if [ -z "$STAGE" ]
then
STAGE=dev
fi
if [ -z "$1" ]
then
aws --profile lfproduct-${STAGE} dynamodb scan --table-name cla-${STAGE}-companies --max-items 100
else
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
fi
11 changes: 11 additions & 0 deletions utils/scan_events.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
if [ -z "$STAGE" ]
then
STAGE=dev
fi
if [ -z "$1" ]
then
aws --profile lfproduct-${STAGE} dynamodb scan --table-name cla-${STAGE}-events --max-items 100
else
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
fi
11 changes: 10 additions & 1 deletion utils/scan_projects.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
#!/bin/bash
aws --profile lfproduct-dev dynamodb scan --table-name cla-dev-projects --max-items 3
if [ -z "$STAGE" ]
then
STAGE=dev
fi
if [ -z "$1" ]
then
aws --profile lfproduct-${STAGE} dynamodb scan --table-name cla-${STAGE}-projects --max-items 100
else
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
fi
7 changes: 6 additions & 1 deletion utils/scan_signatures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ if [ -z "$STAGE" ]
then
STAGE=dev
fi
aws --profile "lfproduct-${STAGE}" dynamodb scan --table-name "cla-${STAGE}-signatures" --max-items 100 | jq -r '.Items'
if [ -z "$1" ]
then
aws --profile "lfproduct-${STAGE}" dynamodb scan --table-name "cla-${STAGE}-signatures" --max-items 100 | jq -r '.Items'
else
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'
fi
12 changes: 12 additions & 0 deletions utils/scan_users.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# add: | jq -r '.[].signature_acl'
if [ -z "$STAGE" ]
then
STAGE=dev
fi
if [ -z "$1" ]
then
aws --profile "lfproduct-${STAGE}" dynamodb scan --table-name "cla-${STAGE}-users" --max-items 100 | jq -r '.Items'
else
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'
fi

0 comments on commit 871101f

Please sign in to comment.