Skip to content

Commit 0476db5

Browse files
New utils scripts for gerrit-instances
Signed-off-by: Lukasz Gryglicki <[email protected]>
1 parent c7eabbe commit 0476db5

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

utils/add_gerrit_server.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
# STAGE=dev gerrit_name='Dev CNCF Gerrit' gerrit_url=http://147.75.85.27:8080 project_sfid=a09P000000DsCE5IAN project_id=01af041c-fa69-4052-a23c-fb8c1d3bef24 ./utils/add_gerrit_server.sh
3+
# {
4+
# "version": {
5+
# "S": "v2"
6+
# },
7+
# "date_modified": {
8+
# "S": "2024-11-22T10:14:27Z"
9+
# },
10+
# "gerrit_url": {
11+
# "S": "https://gerrit.onap.org"
12+
# },
13+
# "gerrit_id": {
14+
# "S": "c2be3edf-a956-438f-ad7d-a03d7d24efce"
15+
# },
16+
# "project_sfid": {
17+
# "S": "a09P000000DsCE5IAN"
18+
# },
19+
# "project_id": {
20+
# "S": "01af041c-fa69-4052-a23c-fb8c1d3bef24"
21+
# },
22+
# "date_created": {
23+
# "S": "2024-11-22T10:14:27Z"
24+
# },
25+
# "gerrit_name": {
26+
# "S": "mock"
27+
# }
28+
# }
29+
if [ -z "$STAGE" ]
30+
then
31+
STAGE=dev
32+
fi
33+
dt_now=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
34+
uuid=$(uuidgen)
35+
if [ -z "${gerrit_url}" ]
36+
then
37+
echo "$0: you need to specify gerrit_url=..."
38+
exit 1
39+
fi
40+
if [ -z "${project_sfid}" ]
41+
then
42+
echo "$0: you need to specify project_sfid=..."
43+
exit 2
44+
fi
45+
if [ -z "${project_id}" ]
46+
then
47+
echo "$0: you need to specify project_id=..."
48+
exit 3
49+
fi
50+
if [ -z "${gerrit_name}" ]
51+
then
52+
echo "$0: you need to specify gerrit_name=..."
53+
exit 4
54+
fi
55+
if [ ! -z "$DEBUG" ]
56+
then
57+
echo aws --profile "lfproduct-${STAGE}" dynamodb put-item --table-name "cla-${STAGE}-gerrit-instances" --item "{\"version\":{\"S\":\"v2\"},\"date_modified\":{\"S\":\"${dt_now}\"},\"gerrit_url\":{\"S\":\"${gerrit_url}\"},\"gerrit_id\":{\"S\":\"${uuid}\"},\"project_sfid\":{\"S\":\"${project_sfid}\"},\"project_id\":{\"S\":\"${project_id}\"},\"date_created\":{\"S\":\"${dt_now}\"},\"gerrit_name\":{\"S\":\"${gerrit_name}\"}}"
58+
fi
59+
aws --profile "lfproduct-${STAGE}" dynamodb put-item --table-name "cla-${STAGE}-gerrit-instances" --item "{\"version\":{\"S\":\"v2\"},\"date_modified\":{\"S\":\"${dt_now}\"},\"gerrit_url\":{\"S\":\"${gerrit_url}\"},\"gerrit_id\":{\"S\":\"${uuid}\"},\"project_sfid\":{\"S\":\"${project_sfid}\"},\"project_id\":{\"S\":\"${project_id}\"},\"date_created\":{\"S\":\"${dt_now}\"},\"gerrit_name\":{\"S\":\"${gerrit_name}\"}}"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
if [ -z "$1" ]
3+
then
4+
echo "$0: you need to specify gerrit_id as a 1st parameter, for example: 'ae9ae8aa-c44c-4181-9b15-4a98f188b711'"
5+
exit 1
6+
fi
7+
8+
if [ -z "$STAGE" ]
9+
then
10+
STAGE=dev
11+
fi
12+
aws --profile "lfproduct-${STAGE}" dynamodb delete-item --table-name "cla-${STAGE}-gerrit-instances" --key "{\"gerrit_id\":{\"S\":\"${1}\"}}"

0 commit comments

Comments
 (0)