#!/usr/bin/env bash

#
# Copyright 2020 Confluent Inc.
#
# Licensed under the Confluent Community License (the "License"); you may not use
# this file except in compliance with the License.  You may obtain a copy of the
# License at
#
# http://www.confluent.io/confluent-community-license
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OF ANY KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations under the License.


dub ensure KSQL_CONNECT_BOOTSTRAP_SERVERS
dub ensure KSQL_CONNECT_GROUP_ID
dub ensure KSQL_CONNECT_CONFIG_STORAGE_TOPIC
dub ensure KSQL_CONNECT_OFFSET_STORAGE_TOPIC
dub ensure KSQL_CONNECT_STATUS_STORAGE_TOPIC
dub ensure KSQL_CONNECT_KEY_CONVERTER
dub ensure KSQL_CONNECT_VALUE_CONVERTER
# This is required to avoid config bugs. You should set this to a value that is
# resolvable by all containers.
dub ensure KSQL_CONNECT_REST_ADVERTISED_HOST_NAME

# Default to 8083, which matches the mesos-overrides. This is here in case we extend the containers to remove the mesos overrides.
if [ -z "$KSQL_CONNECT_REST_PORT" ]; then
  export KSQL_CONNECT_REST_PORT=8083
fi

if [[ $KSQL_CONNECT_KEY_CONVERTER == "io.confluent.connect.avro.AvroConverter" ]]
then
  dub ensure KSQL_CONNECT_KEY_CONVERTER_SCHEMA_REGISTRY_URL
fi

if [[ $KSQL_CONNECT_VALUE_CONVERTER == "io.confluent.connect.avro.AvroConverter" ]]
then
  dub ensure KSQL_CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_URL
fi

