-
Notifications
You must be signed in to change notification settings - Fork 8
/
make-connector
executable file
·53 lines (45 loc) · 1.28 KB
/
make-connector
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
set -e
app_name="$1"
table_name="$2"
usage() {
echo "Usage: $0 HEROKU_APP_NAME POSTGRES_TABLE_NAME"
}
[ -z $app_name ] && {
echo "APP_NAME is missing" >&2
usage
exit 1
}
[ -z $table_name ] && {
echo "TABLE_NAME is missing" >&2
usage
exit 1
}
eval $(heroku config:get -s DATABASE_URL KAFKA_URL -a "$app_name")
url_re='^postgres://([[:alnum:]]+):([[:alnum:]]+)@([-\.[:alnum:]]+):([[:digit:]]+)/([[:alnum:]]+)'
if [[ $DATABASE_URL =~ $url_re ]]; then
user=${BASH_REMATCH[1]}
pass=${BASH_REMATCH[2]}
host=${BASH_REMATCH[3]}
port=${BASH_REMATCH[4]}
database=${BASH_REMATCH[5]}
fi
# cat <<JSON
curl -X POST -H "Content-Type: application/json" -d @- https://${app_name}.herokuapp.com/connectors <<JSON
{
"name": "demo-connector",
"config": {
"connector.class": "io.debezium.connector.postgresql.PostgresConnector",
"tasks.max": "1",
"database.hostname": "${host}",
"database.port": "${port}",
"database.user": "${user}",
"database.password": "${pass}",
"database.dbname" : "${database}",
"database.server.name": "${host}",
"database.whitelist": "${table_name}",
"database.history.kafka.bootstrap.servers": "${KAFKA_URL//kafka+ssl:\/\//}",
"database.history.kafka.topic": "schema-changes.${table_name}"
}
}
JSON