Below is a shell script that I am trying to use to execute dynamic curl calls. The Curl execution calls an API for Kafka. While I know the format of the call is accurate, the url is accurate, and the payload is accurate, I'm getting errors in constructing the payload to send to the API.
Building pipeline for DB1.TB1
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 350 100 349 100 1 43059 123 --:--:-- --:--:-- --:--:-- 49857
curl: (6) Could not resolve host: "name"; Unknown error
curl: (6) Could not resolve host: "database.connection.url":"jdbc:sqlserver; Unknown error
curl: (6) Could not resolve host: "database.hostname"; Unknown error
The error indicates that I am pushing a bad payload. I know if the payload is good, then the call should work, because we tested a static version of the payload without the variables. So I am thinking the string injection is the failure here. Somewhere in the function.
The code reads from teh config file, and for each line item, it goes to create the curl call and executes the call.
Bash validators say my code is good, but it's still failing. I'm hoping for a second set of eyes to tell me where I'm wrong. Thank you.
Script.sh
file='Connector.Config'
create_connector () {
local SHost=${1:?Must Provide Server host}
local source=${2:?Must provide source logical name}
local database=${3:?Must provide database}
local table=${4:?Must provide table}
local payload="$(cat <<END
{
"name":"${source}_${database}_${table}_source",
"database.connection.url":"jdbc:sqlserver://${Shost};databaseName=${database};integratedSecurity=true;authenticationScheme=JavaKerberos",
"database.hostname":"${Shost}",
"database.server.name":"${Shost}.${table}",
"database.dbname":"${database}",
"table.include.list":"dbo.${table}",
"database.history.kafka.bootstrap.servers":"localhost:9092",
"database.history.kafka.topic":"${Sname}_${database}_${table}_history",
"database.user":"sdcservice",
"connector.class":"io.debezium.connector.sqlserver.SqlServerConnector",
"database.integratedSecurity":"true",
"database.authenticationScheme":"JavaKerberos",
"database.password":"",
"time.precision.mode": "connect"
}
END
)"
local makeConnector=$(curl -i -X PUT -H "Content-Type:application/json" \
http://localhost:8083/connectors/${source}_${database}_${table}_source/config \
-d $payload
)
echo ${makeConnector}
echo="$makeConnector"
}
while IFS=, read -r source target database table is_deletable action; do
makeConnector=$(create_connector $Shost $source $database $table)
echo $makeConnector
Example Config File
Source,Target,Database,Table,Is_deletable,Action
DBServer1,DBServer2,DB,TBL1,true,Add
DBServer1,DBServer2,DB,TBL2,true,Add
DBServer1,DBServer2,DB,TBL3,true,Add