-
Notifications
You must be signed in to change notification settings - Fork 211
/
Copy pathutils.sh
executable file
ยท600 lines (564 loc) ยท 21.8 KB
/
utils.sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
DIR_UTILS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source ${DIR_UTILS}/../scripts/cli/src/lib/utils_function.sh
function cleanup-workaround-file {
rm -f /tmp/without-cli-workaround > /dev/null 2>&1
}
if [ ! -f /tmp/playground-run-command-used ]
then
# fm examples not working without using CLI #5635
if [ ! -f /tmp/without-cli-workaround ]
then
trap cleanup-workaround-file EXIT
test_file="$PWD/$0"
filename=$(basename $test_file)
if [[ "$filename" != "playground-command"* ]]
then
playground state set run.test_file "$test_file"
playground state set run.connector_type "$(get_connector_type | tr -d '\n')"
touch /tmp/without-cli-workaround
fi
fi
fi
if [ -z "$FLINK_TAG" ]
then
# FLINK_TAG is not set, use default:
export FLINK_TAG=latest
fi
# Setting up TAG environment variable
#
if [ -z "$TAG" ]
then
# TAG is not set, use default:
export TAG=7.9.0 # default tag
# to handle ubi8 images
export TAG_BASE=$TAG
if [ -z "$CP_KAFKA_IMAGE" ]
then
if [ -z "$IGNORE_CHECK_FOR_DOCKER_COMPOSE" ] && [ -z "$DOCKER_COMPOSE_FILE_UPDATE_VERSION" ]
then
log "๐ซ Using default CP version $TAG"
log "๐ Use --tag option to specify different version, see https://kafka-docker-playground.io/#/how-to-use?id=๐ฏ-for-confluent-platform-cp"
fi
fi
export CP_BASE_IMAGE=confluentinc/cp-base-new
export LEGACY_CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_SSL=""
export CONNECT_USER="appuser"
if [ -z "$CP_ZOOKEEPER_IMAGE" ]
then
export CP_ZOOKEEPER_IMAGE=confluentinc/cp-zookeeper
fi
if [ -z "$CP_KAFKA_IMAGE" ]
then
export CP_KAFKA_IMAGE=confluentinc/cp-server
fi
if [ -z "$CP_CONNECT_IMAGE" ]
then
export CP_CONNECT_IMAGE=confluentinc/cp-server-connect-base
fi
if [ -z "$CP_SCHEMA_REGISTRY_IMAGE" ]
then
export CP_SCHEMA_REGISTRY_IMAGE=confluentinc/cp-schema-registry
fi
if [ -z "$CP_CONTROL_CENTER_IMAGE" ]
then
export CP_CONTROL_CENTER_IMAGE=confluentinc/cp-enterprise-control-center
fi
if [ -z "$CP_REST_PROXY_IMAGE" ]
then
export CP_REST_PROXY_IMAGE=confluentinc/cp-kafka-rest
fi
if [ -z "$CP_KSQL_IMAGE" ]
then
export CP_KSQL_IMAGE=confluentinc/cp-ksqldb-server
fi
if [ -z "$CP_KSQL_CLI_IMAGE" ]
then
export CP_KSQL_CLI_IMAGE=confluentinc/cp-ksqldb-cli:latest
fi
set_kafka_client_tag
else
if [ -z "$CP_KAFKA_IMAGE" ]
then
if [ -z "$IGNORE_CHECK_FOR_DOCKER_COMPOSE" ]
then
log "๐ Using specified CP version $TAG"
fi
fi
if [ -z "$CP_ZOOKEEPER_IMAGE" ]
then
export CP_ZOOKEEPER_IMAGE=confluentinc/cp-zookeeper
fi
if [ -z "$CP_SCHEMA_REGISTRY_IMAGE" ]
then
export CP_SCHEMA_REGISTRY_IMAGE=confluentinc/cp-schema-registry
fi
if [ -z "$CP_REST_PROXY_IMAGE" ]
then
export CP_REST_PROXY_IMAGE=confluentinc/cp-kafka-rest
fi
if [ -z "$CP_CONTROL_CENTER_IMAGE" ]
then
export CP_CONTROL_CENTER_IMAGE=confluentinc/cp-enterprise-control-center
fi
# to handle ubi8 images
export TAG_BASE=$(echo $TAG | cut -d "-" -f1)
first_version=${TAG_BASE}
second_version=5.2.99
if version_gt $first_version $second_version; then
if [ "$first_version" = "5.3.6" ]
then
if [ -z "$CP_KAFKA_IMAGE" ]
then
logwarn "Workaround for 5.3.6 image broker, using custom image vdesabou/cp-server !"
export CP_KAFKA_IMAGE=vdesabou/cp-server
fi
else
if [ -z "$CP_KAFKA_IMAGE" ]
then
export CP_KAFKA_IMAGE=confluentinc/cp-server
fi
fi
else
if [ -z "$CP_KAFKA_IMAGE" ]
then
export CP_KAFKA_IMAGE=confluentinc/cp-enterprise-kafka
fi
fi
second_version=5.3.99
if version_gt $first_version $second_version; then
export CP_BASE_IMAGE=confluentinc/cp-base-new
else
export CP_BASE_IMAGE=confluentinc/cp-base
fi
second_version=5.4.99
if version_gt $first_version $second_version; then
if [ -z "$CP_KSQL_IMAGE" ]
then
export CP_KSQL_IMAGE=confluentinc/cp-ksqldb-server
fi
if [ -z "$CP_KSQL_CLI_IMAGE" ]
then
export CP_KSQL_CLI_IMAGE=confluentinc/cp-ksqldb-cli:${TAG_BASE}
fi
else
if [ -z "$CP_KSQL_IMAGE" ]
then
export CP_KSQL_IMAGE=confluentinc/cp-ksql-server
fi
if [ -z "$CP_KSQL_CLI_IMAGE" ]
then
export CP_KSQL_CLI_IMAGE=confluentinc/cp-ksql-cli:${TAG_BASE}
fi
fi
second_version=5.2.99
if version_gt $first_version $second_version; then
if [ "$first_version" == "5.3.6" ]
then
logwarn "Workaround for ST-6539, using custom image vdesabou/cp-server-connect-base !"
export CP_CONNECT_IMAGE=vdesabou/cp-server-connect-base
else
if [ -z "$CP_CONNECT_IMAGE" ]
then
export CP_CONNECT_IMAGE=confluentinc/cp-server-connect-base
fi
fi
else
if [ -z "$CP_CONNECT_IMAGE" ]
then
export CP_CONNECT_IMAGE=confluentinc/cp-kafka-connect-base
fi
fi
second_version=5.3.99
if version_gt $first_version $second_version; then
export LEGACY_CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_SSL=""
else
if [ -z "$LEGACY_CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_SSL" ]
then
log "๐ด Legacy config for client connecting to HTTPS SR is set, see https://docs.confluent.io/platform/current/schema-registry/security/index.html#additional-configurations-for-https"
export LEGACY_CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_SSL="-Djavax.net.ssl.trustStore=/etc/kafka/secrets/kafka.connect.truststore.jks -Djavax.net.ssl.trustStorePassword=confluent -Djavax.net.ssl.keyStore=/etc/kafka/secrets/kafka.connect.keystore.jks -Djavax.net.ssl.keyStorePassword=confluent"
fi
fi
set_kafka_client_tag
fi
# Setting grafana agent based
if [ -z "$ENABLE_JMX_GRAFANA" ]
then
# defaulting to empty variable since this is default in kafka-run-class.sh & avoid warning
export GRAFANA_AGENT_ZK=""
export GRAFANA_AGENT_BROKER=""
export GRAFANA_AGENT_CONNECT=""
export GRAFANA_AGENT_PRODUCER=""
export GRAFANA_AGENT_CONSUMER=""
export GRAFANA_AGENT_SR=""
export GRAFANA_AGENT_KSQLDB=""
export GRAFANA_FLINK=""
else
export GRAFANA_AGENT_ZK="-javaagent:/usr/share/jmx_exporter/pyroscope-0.11.2.jar -javaagent:/usr/share/jmx_exporter/jmx_prometheus_javaagent-0.20.0.jar=1234:/usr/share/jmx_exporter/zookeeper.yml"
export GRAFANA_AGENT_BROKER="-javaagent:/usr/share/jmx_exporter/pyroscope-0.11.2.jar -javaagent:/usr/share/jmx_exporter/jmx_prometheus_javaagent-0.20.0.jar=1234:/usr/share/jmx_exporter/kafka_broker.yml"
export GRAFANA_AGENT_CONNECT="-javaagent:/usr/share/jmx_exporter/pyroscope-0.11.2.jar -javaagent:/usr/share/jmx_exporter/jmx_prometheus_javaagent-0.20.0.jar=1234:/usr/share/jmx_exporter/kafka_connect.yml"
export GRAFANA_AGENT_PRODUCER="-javaagent:/usr/share/jmx_exporter/pyroscope-0.11.2.jar -javaagent:/usr/share/jmx_exporter/jmx_prometheus_javaagent-0.20.0.jar=1234:/usr/share/jmx_exporter/kafka-producer.yml"
export GRAFANA_AGENT_CONSUMER="-javaagent:/usr/share/jmx_exporter/pyroscope-0.11.2.jar -javaagent:/usr/share/jmx_exporter/jmx_prometheus_javaagent-0.20.0.jar=1234:/usr/share/jmx_exporter/kafka-consumer.yml"
export GRAFANA_AGENT_SR="-javaagent:/usr/share/jmx_exporter/pyroscope-0.11.2.jar -javaagent:/usr/share/jmx_exporter/jmx_prometheus_javaagent-0.20.0.jar=1234:/usr/share/jmx_exporter/confluent_schemaregistry.yml"
export GRAFANA_AGENT_KSQLDB="-javaagent:/usr/share/jmx_exporter/pyroscope-0.11.2.jar -javaagent:/usr/share/jmx_exporter/jmx_prometheus_javaagent-0.20.0.jar=1234:/usr/share/jmx_exporter/confluent_ksql.yml"
export GRAFANA_FLINK="metrics.reporter.prom.factory.class: org.apache.flink.metrics.prometheus.PrometheusReporterFactory
metrics.reporter.prom.port: 9090"
fi
# Migrate SimpleAclAuthorizer to AclAuthorizer #1276
if version_gt $TAG "5.3.99"
then
export KAFKA_AUTHORIZER_CLASS_NAME="kafka.security.authorizer.AclAuthorizer"
else
export KAFKA_AUTHORIZER_CLASS_NAME="kafka.security.auth.SimpleAclAuthorizer"
fi
if [ ! -z "$CONNECTOR_TAG" ] && [ ! -z "$CONNECTOR_ZIP" ]
then
logerror "CONNECTOR_TAG and CONNECTOR_ZIP are both set, they cannot be used at same time!"
exit 1
fi
###
# CONNECTOR_TAG is set
###
if [ ! -z "$CONNECTOR_TAG" ]
then
if [[ $0 == *"environment"* ]]
then
# log "DEBUG: start.sh from environment folder. Skipping..."
if [ -z "$CONNECT_TAG" ]
then
export CONNECT_TAG="$TAG"
fi
:
elif [[ $0 == *"stop.sh"* ]]
then
if [ -z "$CONNECT_TAG" ]
then
export CONNECT_TAG="$TAG"
fi
:
elif [[ $0 == *"run-tests"* ]]
then
:
else
if [ -z "$IGNORE_CHECK_FOR_DOCKER_COMPOSE" ]
then
log "๐ฏ CONNECTOR_TAG (--connector-tag option) is set with version $CONNECTOR_TAG"
fi
# determining the connector from current path
docker_compose_file=""
if [ ! -z "$DOCKER_COMPOSE_FILE_UPDATE_VERSION" ]
then
docker_compose_file=$DOCKER_COMPOSE_FILE_UPDATE_VERSION
elif [ -f "$PWD/$0" ]
then
docker_compose_file=$(grep "start-environment" "$PWD/$0" | awk '{print $6}' | cut -d "/" -f 2 | cut -d '"' -f 1 | tail -n1 | xargs)
fi
if [ "${docker_compose_file}" != "" ] && [ -f "${docker_compose_file}" ]
then
connector_paths=$(grep "CONNECT_PLUGIN_PATH" "${docker_compose_file}" | grep -v "KSQL_CONNECT_PLUGIN_PATH" | cut -d ":" -f 2 | tr -s " " | head -1)
if [ "$connector_paths" == "" ]
then
# not a connector test
if [ -z "$CONNECT_TAG" ]
then
export CONNECT_TAG="$TAG"
fi
else
###
# Loop on all connectors in CONNECT_PLUGIN_PATH and install latest version from Confluent Hub (except for JDBC and replicator)
###
first_loop=true
i=0
my_array_connector_tag=($(echo $CONNECTOR_TAG | tr "," "\n"))
for connector_path in ${connector_paths//,/ }
do
connector_path=$(echo "$connector_path" | cut -d "/" -f 5)
owner=$(echo "$connector_path" | cut -d "-" -f 1)
name=$(echo "$connector_path" | cut -d "-" -f 2-)
CONNECTOR_VERSION="${my_array_connector_tag[$i]}"
if [ "$CONNECTOR_VERSION" = "" ]
then
logwarn "CONNECTOR_TAG (--connector-tag option) was not set for element $i, setting it to latest"
CONNECTOR_VERSION="latest"
fi
export CONNECT_TAG="$TAG"
maybe_create_image
if [ "$first_loop" = true ]
then
if [[ "$OSTYPE" == "darwin"* ]]
then
rm -rf ${DIR_UTILS}/../confluent-hub
else
log "Using sudo to remove ${DIR_UTILS}/../confluent-hub"
sudo rm -rf ${DIR_UTILS}/../confluent-hub
fi
mkdir -p ${DIR_UTILS}/../confluent-hub
fi
log "๐ฑ Installing connector $owner/$name:$CONNECTOR_VERSION"
set +e
docker run -u0 -i --rm -v ${DIR_UTILS}/../confluent-hub:/usr/share/confluent-hub-components ${CP_CONNECT_IMAGE}:${CONNECT_TAG} bash -c "confluent-hub install --no-prompt $owner/$name:$CONNECTOR_VERSION && chown -R $(id -u $USER):$(id -g $USER) /usr/share/confluent-hub-components" > /tmp/result.log 2>&1
if [ $? != 0 ]
then
logerror "โ failed to install connector $owner/$name:$CONNECTOR_VERSION"
tail -500 /tmp/result.log
exit 1
else
grep "Download" /tmp/result.log
fi
set -e
log "๐ค Listing jar files"
cd ${DIR_UTILS}/../confluent-hub/$owner-$name/lib > /dev/null 2>&1
ls -1 | sort
cd - > /dev/null 2>&1
if [ "$first_loop" = true ]
then
first_loop=false
###
# CONNECTOR_JAR is set (and also CONNECTOR_TAG)
###
if [ ! -z "$CONNECTOR_JAR" ]
then
if [ ! -f "$CONNECTOR_JAR" ]
then
logerror "โ jar file specified by CONNECTOR_JAR (--connector-jar option) $CONNECTOR_JAR does not exist!"
exit 1
fi
if [ -z "$IGNORE_CHECK_FOR_DOCKER_COMPOSE" ]
then
log "๐ฏโ CONNECTOR_JAR (--connector-jar option) is set with $CONNECTOR_JAR"
fi
connector_jar_name=$(basename ${CONNECTOR_JAR})
current_jar_path="${DIR_UTILS}/../confluent-hub/$connector_path/lib/$name-$CONNECTOR_TAG.jar"
set +e
ls $current_jar_path
if [ $? -ne 0 ]
then
logwarn "$connector_path/lib/$name-$CONNECTOR_TAG.jar does not exist, the jar name to replace could not be found automatically"
array=($(ls ${DIR_UTILS}/../confluent-hub/$connector_path/lib | grep $CONNECTOR_TAG))
choosejar "${array[@]}"
current_jar_path="${DIR_UTILS}/../confluent-hub/$connector_path/lib/$jar"
fi
set -e
log "๐ฎ Remplacing $name-$CONNECTOR_TAG.jar by $connector_jar_name"
cp $CONNECTOR_JAR $current_jar_path
maybe_create_image
fi
fi
((i=i+1))
done
fi
else
if [ -z "$IGNORE_CHECK_FOR_DOCKER_COMPOSE" ] && [ "$0" != "/tmp/playground-command" ] && [ "$0" != "/tmp/playground-command-debugging" ]
then
logerror "๐ Could not determine docker-compose override file from $PWD/$0 !"
logerror "๐ Please check you're running a connector example !"
logerror "๐ Check the related documentation https://kafka-docker-playground.io/#/how-it-works?id=๐ณ-docker-override"
exit 1
else
if [ -z "$CONNECT_TAG" ]
then
export CONNECT_TAG="$TAG"
fi
fi
fi
fi
else
###
# CONNECTOR_TAG is not set
###
if [[ $0 == *"environment"* ]]
then
if [ -z "$CONNECT_TAG" ]
then
export CONNECT_TAG="$TAG"
fi
:
elif [[ $0 == *"stop.sh"* ]]
then
if [ -z "$CONNECT_TAG" ]
then
export CONNECT_TAG="$TAG"
fi
CONNECTOR_TAG=$version
:
elif [[ $0 == *"run-tests"* ]]
then
:
else
docker_compose_file=""
if [ ! -z "$DOCKER_COMPOSE_FILE_UPDATE_VERSION" ]
then
docker_compose_file=$DOCKER_COMPOSE_FILE_UPDATE_VERSION
elif [ -f "$PWD/$0" ]
then
docker_compose_file=$(grep "start-environment" "$PWD/$0" | awk '{print $6}' | cut -d "/" -f 2 | cut -d '"' -f 1 | tail -n1 | xargs)
fi
if [ "${docker_compose_file}" != "" ] && [ -f "${docker_compose_file}" ]
then
connector_paths=$(grep "CONNECT_PLUGIN_PATH" "${docker_compose_file}" | grep -v "KSQL_CONNECT_PLUGIN_PATH" | cut -d ":" -f 2 | tr -s " " | head -1)
if [ "$connector_paths" == "" ]
then
# not a connector test
if [ -z "$CONNECT_TAG" ]
then
export CONNECT_TAG="$TAG"
maybe_create_image
fi
else
###
# Loop on all connectors in CONNECT_PLUGIN_PATH and install latest version from Confluent Hub (except for JDBC and replicator)
###
first_loop=true
if [[ "$OSTYPE" == "darwin"* ]]
then
rm -rf ${DIR_UTILS}/../confluent-hub
else
log "Using sudo to remove ${DIR_UTILS}/../confluent-hub"
sudo rm -rf ${DIR_UTILS}/../confluent-hub
fi
mkdir -p ${DIR_UTILS}/../confluent-hub
for connector_path in ${connector_paths//,/ }
do
connector_path=$(echo "$connector_path" | cut -d "/" -f 5)
owner=$(echo "$connector_path" | cut -d "-" -f 1)
name=$(echo "$connector_path" | cut -d "-" -f 2-)
if [ "$name" == "" ]
then
# can happen for filestream
if [ -z "$CONNECT_TAG" ]
then
export CONNECT_TAG="$TAG"
maybe_create_image
fi
else
if [ -z "$CONNECT_TAG" ]
then
export CONNECT_TAG="$TAG"
fi
###
# CONNECTOR_ZIP is set
###
if [ ! -z "$CONNECTOR_ZIP" ] && [ "$first_loop" = true ]
then
if [ ! -f "$CONNECTOR_ZIP" ]
then
logerror "CONNECTOR_ZIP $CONNECTOR_ZIP does not exist!"
exit 1
fi
log "๐ฏ๐ค CONNECTOR_ZIP (--connector-zip option) is set with $CONNECTOR_ZIP"
connector_zip_name=$(basename ${CONNECTOR_ZIP})
cp $CONNECTOR_ZIP /tmp/
maybe_create_image
log "๐ฑ Installing connector from zip $connector_zip_name"
set +e
docker run -u0 -i --rm -v ${DIR_UTILS}/../confluent-hub:/usr/share/confluent-hub-components -v /tmp:/tmp ${CP_CONNECT_IMAGE}:${CONNECT_TAG} bash -c "confluent-hub install --no-prompt /tmp/${connector_zip_name} && chown -R $(id -u $USER):$(id -g $USER) /usr/share/confluent-hub-components" > /tmp/result.log 2>&1
if [ $? != 0 ]
then
logerror "โ failed to install connector from zip $connector_zip_name"
tail -500 /tmp/result.log
exit 1
else
grep "Installing" /tmp/result.log
fi
set -e
first_loop=false
continue
fi
version_to_get_from_hub="latest"
if [ "$name" = "kafka-connect-replicator" ]
then
if [ -z "$REPLICATOR_TAG" ]
then
version_to_get_from_hub="$TAG"
else
version_to_get_from_hub="$REPLICATOR_TAG"
log "๐ REPLICATOR_TAG is set with $REPLICATOR_TAG"
fi
fi
if [ "$name" = "kafka-connect-jdbc" ]
then
if ! version_gt $TAG_BASE "5.9.0"; then
# for version less than 6.0.0, use JDBC with same version
# see https://github.com/vdesabou/kafka-docker-playground/issues/221
version_to_get_from_hub="$TAG_BASE"
fi
if [ "$TAG_BASE" = "5.0.2" ] || [ "$TAG_BASE" = "5.0.3" ]
then
version_to_get_from_hub="5.0.1"
fi
fi
maybe_create_image
log "๐ฑ Installing connector $owner/$name:$version_to_get_from_hub"
set +e
docker run -u0 -i --rm -v ${DIR_UTILS}/../confluent-hub:/usr/share/confluent-hub-components ${CP_CONNECT_IMAGE}:${CONNECT_TAG} bash -c "confluent-hub install --no-prompt $owner/$name:$version_to_get_from_hub && chown -R $(id -u $USER):$(id -g $USER) /usr/share/confluent-hub-components" > /tmp/result.log 2>&1
if [ $? != 0 ]
then
logerror "โ failed to install connector $owner/$name:$version_to_get_from_hub"
tail -500 /tmp/result.log
exit 1
else
grep "Download" /tmp/result.log
fi
set -e
log "๐ค Listing jar files"
cd ${DIR_UTILS}/../confluent-hub/$owner-$name/lib > /dev/null 2>&1
ls -1 | sort
cd - > /dev/null 2>&1
version=$(cat ${DIR_UTILS}/../confluent-hub/${connector_path}/manifest.json | jq -r '.version')
release_date=$(cat ${DIR_UTILS}/../confluent-hub/${connector_path}/manifest.json | jq -r '.release_date')
documentation_url=$(cat ${DIR_UTILS}/../confluent-hub/${connector_path}/manifest.json | jq -r '.documentation_url')
###
# CONNECTOR_JAR is set
###
if [ ! -z "$CONNECTOR_JAR" ] && [ "$first_loop" = true ]
then
if [ ! -f "$CONNECTOR_JAR" ]
then
logerror "โ CONNECTOR_JAR $CONNECTOR_JAR does not exist!"
exit 1
fi
log "๐ฏโ CONNECTOR_JAR (--connector-jar option) is set with $CONNECTOR_JAR"
connector_jar_name=$(basename ${CONNECTOR_JAR})
current_jar_path="${DIR_UTILS}/../confluent-hub/$connector_path/lib/$name-$version.jar"
set +e
ls $current_jar_path
if [ $? -ne 0 ]
then
logwarn "โ $connector_path/lib/$name-$version.jar does not exist, the jar name to replace could not be found automatically"
array=($(ls ${DIR_UTILS}/../confluent-hub/$connector_path/lib | grep $version))
choosejar "${array[@]}"
current_jar_path="${DIR_UTILS}/../confluent-hub/$connector_path/lib/$jar"
fi
set -e
log "๐ฎ Remplacing $name-$version.jar by $connector_jar_name"
cp $CONNECTOR_JAR $current_jar_path
maybe_create_image
###
# Neither CONNECTOR_ZIP or CONNECTOR_JAR are set
###
else
if [ -z "$CONNECT_TAG" ]
then
export CONNECT_TAG="$TAG"
fi
if [ "$first_loop" = true ]
then
log "๐ซ Using connector:"
log " ๐ Plugin: $owner/$name:$version"
log " ๐
Release date: $release_date"
log " ๐ Documentation: $documentation_url"
# echo "๐ซ ๐ $owner/$name:$version ๐
$release_date ๐ $documentation_url" > /tmp/connector_info
log "๐ To specify different version, check the documentation https://kafka-docker-playground.io/#/how-to-use?id=๐-for-connectors"
CONNECTOR_TAG=$version
fi
fi
first_loop=false
fi
done
fi
fi
fi
if [ -z "$CONNECT_TAG" ]
then
export CONNECT_TAG="$TAG"
fi
fi