1
- echo " NEEDED ENV Variables are: [PLUGIN_ID , ES_INDEX_PREFIX, DB_PASSWORD, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, ENDPOINT_URL, ELASTICSEARCH_PASSWORD, OPENSSL_PASSWORD, DEMO_DATA_S3_PATH]"
1
+ echo " NEEDED ENV Variables are: [INTEGRATION_TYPE , ES_INDEX_PREFIX, DB_PASSWORD, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, ENDPOINT_URL, ELASTICSEARCH_PASSWORD, OPENSSL_PASSWORD, DEMO_DATA_S3_PATH]"
2
2
3
- mkdir -p /tmp/demo-data
3
+ rm -rf /tmp/demo-data
4
4
5
+ mkdir -p /tmp/demo-data
6
+ echo " $DB_PASSWORD "
5
7
6
8
DB_HOST=" ${DB_HOST:- localhost} "
7
9
DB_PORT=" ${DB_PORT:- 5432} "
@@ -15,8 +17,8 @@ if [ -z "$DB_PASSWORD" ]; then
15
17
exit 1
16
18
fi
17
19
18
- if [ -z " $PLUGIN_ID " ]; then
19
- echo " Error: PLUGIN_ID environment variable is not set." >&2
20
+ if [ -z " $INTEGRATION_TYPE " ]; then
21
+ echo " Error: INTEGRATION_TYPE environment variable is not set." >&2
20
22
exit 1
21
23
fi
22
24
27
29
28
30
export PGPASSWORD=" $DB_PASSWORD "
29
31
30
- SQL_QUERY=$( cat << - EOF
32
+ SQL_QUERY=$( cat << EOF
31
33
SELECT
32
34
json_build_object(
33
- 'integrationId', integration_id::text, -- Cast UUID to text if needed
35
+ 'integrationId', integration_id::text,
34
36
'providerId', provider_id,
35
37
'name', name,
36
- 'integrationType', integration_type, -- Assuming it's stored as text compatible with your Go type
37
- 'annotations', annotations, -- Assuming annotations is a JSONB column
38
- 'labels', labels -- Assuming labels is a JSONB column
38
+ 'integrationType', integration_type,
39
+ 'annotations', annotations,
40
+ 'labels', labels
39
41
)
40
42
FROM
41
43
integrations
42
44
WHERE
43
- integration_type = '${PLUGIN_ID } ';
45
+ integration_type = '${INTEGRATION_TYPE } ';
44
46
EOF
45
47
)
46
48
47
- echo " Connecting to database ' $DB_NAME ' on ' $DB_HOST :$DB_PORT ' as user ' $DB_USER ' ..."
48
- echo " Executing query and exporting to ' $OUTPUT_FILE ' ..."
49
+ echo " Connecting to database $DB_NAME on $DB_HOST :$DB_PORT as user $DB_USER ..."
50
+ echo " Executing query and exporting to $OUTPUT_FILE ..."
49
51
50
52
psql -X -A -t -q -v ON_ERROR_STOP=1 \
51
53
-h " $DB_HOST " \
52
54
-p " $DB_PORT " \
53
55
-U " $DB_USER " \
54
56
-d " $DB_NAME " \
55
57
-c " $SQL_QUERY " | \
56
- jq -s ' . ' > " $OUTPUT_FILE "
58
+ jq -s " . " > " $OUTPUT_FILE "
57
59
58
60
if [ -s " $OUTPUT_FILE " ]; then
59
- echo " Successfully exported integrations to ' $OUTPUT_FILE ' ."
61
+ echo " Successfully exported integrations to $OUTPUT_FILE ."
60
62
else
61
63
echo " Error: Failed to export data or the table is empty. Output file is empty or not created." >&2
62
64
exit 1
@@ -92,20 +94,16 @@ export NODE_TLS_REJECT_UNAUTHORIZED=0
92
94
multielasticdump \
93
95
--direction=dump \
94
96
--input=" $NEW_ELASTICSEARCH_ADDRESS " \
95
- --output=" /tmp/demo-data/es-demo/ " \
97
+ --output=" /tmp/demo-data/es-demo" \
96
98
--parallel=20 \
97
- --match=' ^ ' ${ES_INDEX_PREFIX} ' .*$' \
99
+ --match=" ^ ${ES_INDEX_PREFIX} .*$" \
98
100
--matchType=alias \
99
101
--limit=10000 \
100
102
--scrollTime=10m \
101
- --searchBody=' { "query": {"bool": {"must_not": {"term": {"deleted": true}}}}}' \
103
+ --searchBody=" { \ " query\ " : {\ " bool\ " : {\ " must_not\ " : {\ " term\ " : {\ " deleted\ " : true}}}}}" \
102
104
--ignoreTemplate=true
103
105
104
106
cd /tmp
105
- tar -cO demo-data | openssl enc -aes-256-cbc -md md5 -pass pass:" $OPENSSL_PASSWORD " -base64 > demo_data.tar.gz.enc
106
-
107
- FILE_SIZE_BYTES=$( stat -c %s /tmp/demo_data.tar.gz.enc)
108
- FILE_SIZE_MB=$( echo " scale=2; $FILE_SIZE_BYTES / 1048576" | bc)
109
- echo " File size: ${FILE_SIZE_MB} MB"
107
+ tar -cf - demo-data | openssl enc -aes-256-cbc -md md5 -pass pass:" $OPENSSL_PASSWORD " -base64 > demo_data.tar.gz.enc
110
108
111
109
rclone copy /tmp/demo_data.tar.gz.enc " $DEMO_DATA_S3_PATH "
0 commit comments