From 132a08a7b1e3df6c09424c86283c27053ef7da31 Mon Sep 17 00:00:00 2001 From: mark-labuschagne Date: Thu, 20 Oct 2022 10:51:29 +0200 Subject: [PATCH 1/7] added --with-registry-auth flag to deploys PLAT-524 --- analytics-datastore-clickhouse/swarm.sh | 6 +++--- analytics-datastore-elastic-search/swarm.sh | 8 ++++---- client-registry-santempi/swarm.sh | 10 +++++----- dashboard-visualiser-jsreport/swarm.sh | 6 +++--- dashboard-visualiser-kibana/swarm.sh | 6 +++--- dashboard-visualiser-superset/swarm.sh | 6 +++--- data-mapper-logstash/swarm.sh | 2 +- fhir-datastore-hapi-fhir/swarm.sh | 8 ++++---- interoperability-layer-openhim/swarm.sh | 16 ++++++++-------- job-scheduler-ofelia/swarm.sh | 2 +- kafka-mapper-consumer/swarm.sh | 2 +- kafka-unbundler-consumer/swarm.sh | 2 +- message-bus-helper-hapi-proxy/swarm.sh | 8 ++++---- message-bus-kafka/swarm.sh | 5 ++--- reverse-proxy-nginx/swarm.sh | 4 ++-- 15 files changed, 45 insertions(+), 46 deletions(-) diff --git a/analytics-datastore-clickhouse/swarm.sh b/analytics-datastore-clickhouse/swarm.sh index ac0f79f7..76057470 100755 --- a/analytics-datastore-clickhouse/swarm.sh +++ b/analytics-datastore-clickhouse/swarm.sh @@ -26,7 +26,7 @@ main() { fi if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $clickhouse_dev_compose_param instant" "Failed to deploy Analytics Datastore Clickhouse" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $clickhouse_dev_compose_param --with-registry-auth instant" "Failed to deploy Analytics Datastore Clickhouse" docker::await_container_startup analytics-datastore-clickhouse docker::await_container_status analytics-datastore-clickhouse Running @@ -35,10 +35,10 @@ main() { log info "Setting config digests" config::set_config_digests "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to start config importer" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to start config importer" log info "Waiting to give core config importer time to run before cleaning up service" - + config::remove_config_importer clickhouse-config-importer # Ensure config importer is removed diff --git a/analytics-datastore-elastic-search/swarm.sh b/analytics-datastore-elastic-search/swarm.sh index 504f172b..1a6dbae3 100644 --- a/analytics-datastore-elastic-search/swarm.sh +++ b/analytics-datastore-elastic-search/swarm.sh @@ -33,7 +33,7 @@ import_elastic_index() { # TODO: (castelloG) [PLAT-255] Add support for multiple index imports log info "Importing Elasticsearch index mapping" config::set_config_digests "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to start elastic search config importer" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to start elastic search config importer" config::remove_stale_service_configs "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml "elastic-search" config::remove_config_importer elastic-search-config-importer } @@ -56,7 +56,7 @@ fi create_certs() { log info "Creating certificates" - try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.certs.yml instant" "Creating certificates failed" + try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.certs.yml --with-registry-auth instant" "Creating certificates failed" docker::await_container_startup create_certs docker::await_container_status create_certs Complete @@ -113,13 +113,13 @@ add_docker_configs() { if [[ "$ACTION" == "init" ]]; then if [[ "$STATEFUL_NODES" == "cluster" ]]; then create_certs - try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.cluster.yml instant" "Failed to deploy cluster" + try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.cluster.yml --with-registry-auth instant" "Failed to deploy cluster" add_docker_configs log info "Waiting for elasticsearch to start before automatically setting built-in passwords" docker::await_container_status $leader_node Running else - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $elastic_search_dev_compose_param instant" "Failed to deploy Analytics Datastore Elastic Search" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $elastic_search_dev_compose_param --with-registry-auth instant" "Failed to deploy Analytics Datastore Elastic Search" log info "Waiting for elasticsearch to start before automatically setting built-in passwords" docker::await_container_status $leader_node Starting diff --git a/client-registry-santempi/swarm.sh b/client-registry-santempi/swarm.sh index 5c40e5ec..c8bb8e35 100644 --- a/client-registry-santempi/swarm.sh +++ b/client-registry-santempi/swarm.sh @@ -51,17 +51,17 @@ main() { fi if [ "$ACTION" == "init" ]; then - try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose-postgres.yml $POSTGRES_CLUSTER_COMPOSE_PARAM $POSTGRES_DEV_COMPOSE_PARAM instant" "Failed to deploy SanteMPI Postgres" + try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose-postgres.yml $POSTGRES_CLUSTER_COMPOSE_PARAM $POSTGRES_DEV_COMPOSE_PARAM --with-registry-auth instant" "Failed to deploy SanteMPI Postgres" await_postgres_start - try "docker stack deploy -c "$COMPOSE_FILE_PATH"/docker-compose.yml $SANTE_MPI_DEV_COMPOSE_PARAM instant" "Failed to deploy SanteMPI" + try "docker stack deploy -c "$COMPOSE_FILE_PATH"/docker-compose.yml $SANTE_MPI_DEV_COMPOSE_PARAM --with-registry-auth instant" "Failed to deploy SanteMPI" elif [ "$ACTION" == "up" ]; then - try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose-postgres.yml $POSTGRES_CLUSTER_COMPOSE_PARAM $POSTGRES_DEV_COMPOSE_PARAM instant" "Failed to stand up SanteMPI Postgres" + try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose-postgres.yml $POSTGRES_CLUSTER_COMPOSE_PARAM $POSTGRES_DEV_COMPOSE_PARAM --with-registry-auth instant" "Failed to stand up SanteMPI Postgres" await_postgres_start - try "docker stack deploy -c "$COMPOSE_FILE_PATH"/docker-compose.yml $SANTE_MPI_DEV_COMPOSE_PARAM instant" "Failed to stand up SanteMPI" + try "docker stack deploy -c "$COMPOSE_FILE_PATH"/docker-compose.yml $SANTE_MPI_DEV_COMPOSE_PARAM --with-registry-auth instant" "Failed to stand up SanteMPI" elif [ "$ACTION" == "down" ]; then try "docker service scale instant_santedb-mpi=0 instant_santempi-psql-1=0" "Failed to scale down santeMPI" @@ -70,7 +70,7 @@ main() { fi elif [ "$ACTION" == "destroy" ]; then - docker::service_destroy santedb-www + docker::service_destroy santedb-www docker::service_destroy santedb-mpi docker::service_destroy santempi-psql-1 docker::try_remove_volume santedb-data diff --git a/dashboard-visualiser-jsreport/swarm.sh b/dashboard-visualiser-jsreport/swarm.sh index 4a4566ee..3ad69250 100644 --- a/dashboard-visualiser-jsreport/swarm.sh +++ b/dashboard-visualiser-jsreport/swarm.sh @@ -44,14 +44,14 @@ main() { if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then unbound_ES_HOSTS_check - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $js_report_dev_compose_param $js_report_dev_mount_compose_param instant" "Failed to deploy JS Report" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $js_report_dev_compose_param $js_report_dev_mount_compose_param --with-registry-auth instant" "Failed to deploy JS Report" if [[ "${JS_REPORT_DEV_MOUNT}" != "true" ]]; then log info "Verifying JS Report service status" config::await_service_running "dashboard-visualiser-jsreport" "${COMPOSE_FILE_PATH}"/docker-compose.await-helper.yml "${JS_REPORT_INSTANCES}" config::set_config_digests "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to start config importer" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to start config importer" config::remove_config_importer "jsreport-config-importer" config::remove_stale_service_configs "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml "jsreport" @@ -62,7 +62,7 @@ main() { docker::service_destroy dashboard-visualiser-jsreport docker::service_destroy jsreport-config-importer docker::service_destroy await-helper - + docker::prune_configs "jsreport" else log error "Valid options are: init, up, down, or destroy" diff --git a/dashboard-visualiser-kibana/swarm.sh b/dashboard-visualiser-kibana/swarm.sh index beb3390b..1c1b58f1 100644 --- a/dashboard-visualiser-kibana/swarm.sh +++ b/dashboard-visualiser-kibana/swarm.sh @@ -19,7 +19,7 @@ readonly ROOT_PATH import_kibana_dashboards() { log info "Importing Kibana dashboard" config::set_config_digests "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to start config importer" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to start config importer" config::remove_config_importer "kibana-config-importer" config::remove_stale_service_configs "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml "kibana" } @@ -42,7 +42,7 @@ main() { fi config::set_config_digests "${COMPOSE_FILE_PATH}"/docker-compose.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $kibana_dev_compose_param instant" "Failed to deploy Dashboard Visualiser Kibana" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $kibana_dev_compose_param --with-registry-auth instant" "Failed to deploy Dashboard Visualiser Kibana" docker::await_container_startup dashboard-visualiser-kibana docker::await_container_status dashboard-visualiser-kibana Running @@ -51,7 +51,7 @@ main() { log info "Setting config digests" config::set_config_digests "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to start config importer" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to start config importer" import_kibana_dashboards elif [[ "${ACTION}" == "down" ]]; then diff --git a/dashboard-visualiser-superset/swarm.sh b/dashboard-visualiser-superset/swarm.sh index a1411803..29e240ff 100644 --- a/dashboard-visualiser-superset/swarm.sh +++ b/dashboard-visualiser-superset/swarm.sh @@ -27,7 +27,7 @@ main() { if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then config::set_config_digests "$COMPOSE_FILE_PATH"/docker-compose.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $superset_dev_compose_param instant" "Failed to deploy Dashboard Visualiser Superset" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $superset_dev_compose_param --with-registry-auth instant" "Failed to deploy Dashboard Visualiser Superset" docker::await_container_startup dashboard-visualiser-superset docker::await_container_status dashboard-visualiser-superset Running @@ -36,10 +36,10 @@ main() { log info "Setting config digests" config::set_config_digests "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to start config importer" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to start config importer" log info "Waiting to give core config importer time to run before cleaning up service" - + config::remove_config_importer superset-config-importer # Ensure config importer is removed diff --git a/data-mapper-logstash/swarm.sh b/data-mapper-logstash/swarm.sh index deb1211d..e1df6082 100644 --- a/data-mapper-logstash/swarm.sh +++ b/data-mapper-logstash/swarm.sh @@ -59,7 +59,7 @@ if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then config::generate_service_configs data-mapper-logstash /usr/share/logstash "${COMPOSE_FILE_PATH}/pipeline" "${COMPOSE_FILE_PATH}" logstash LogstashTempComposeParam="-c ${COMPOSE_FILE_PATH}/docker-compose.tmp.yml" - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $LogstashDevComposeParam $LogstashDevMountComposeParam $LogstashTempComposeParam instant" "Failed to deploy Data Mapper Logstash" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $LogstashDevComposeParam $LogstashDevMountComposeParam $LogstashTempComposeParam --with-registry-auth instant" "Failed to deploy Data Mapper Logstash" docker::await_container_startup data-mapper-logstash docker::await_container_status data-mapper-logstash Running diff --git a/fhir-datastore-hapi-fhir/swarm.sh b/fhir-datastore-hapi-fhir/swarm.sh index 86bdf463..a324c2fc 100644 --- a/fhir-datastore-hapi-fhir/swarm.sh +++ b/fhir-datastore-hapi-fhir/swarm.sh @@ -50,17 +50,17 @@ else fi if [ "${ACTION}" == "init" ]; then - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose-postgres.yml $postgresClusterComposeParam $postgresDevComposeParam instant" "Failed to deploy FHIR Datastore HAPI FHIR Postgres" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose-postgres.yml $postgresClusterComposeParam $postgresDevComposeParam --with-registry-auth instant" "Failed to deploy FHIR Datastore HAPI FHIR Postgres" await_postgres_start - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $hapiFhirDevComposeParam instant" "Failed to deploy FHIR Datastore HAPI FHIR" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $hapiFhirDevComposeParam --with-registry-auth instant" "Failed to deploy FHIR Datastore HAPI FHIR" elif [ "${ACTION}" == "up" ]; then - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose-postgres.yml $postgresClusterComposeParam $postgresDevComposeParam instant" "Failed to stand up hapi-fhir postgres" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose-postgres.yml $postgresClusterComposeParam $postgresDevComposeParam --with-registry-auth instant" "Failed to stand up hapi-fhir postgres" await_postgres_start - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $hapiFhirDevComposeParam instant" "Failed to stand up hapi-fhir" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $hapiFhirDevComposeParam --with-registry-auth instant" "Failed to stand up hapi-fhir" elif [ "${ACTION}" == "down" ]; then try "docker service scale instant_hapi-fhir=0 instant_postgres-1=0" "Failed to scale down hapi-fhir" diff --git a/interoperability-layer-openhim/swarm.sh b/interoperability-layer-openhim/swarm.sh index eab81657..9a44b589 100644 --- a/interoperability-layer-openhim/swarm.sh +++ b/interoperability-layer-openhim/swarm.sh @@ -88,7 +88,7 @@ main() { config::set_config_digests "${COMPOSE_FILE_PATH}"/docker-compose.yml config::set_config_digests "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose-mongo.yml $mongo_cluster_compose_param $mongo_dev_compose_param instant" "Failed to deploy mongo" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose-mongo.yml $mongo_cluster_compose_param $mongo_dev_compose_param --with-registry-auth instant" "Failed to deploy mongo" if [[ "${STATEFUL_NODES}" == "cluster" ]]; then try "${COMPOSE_FILE_PATH}/initiateReplicaSet.sh" "Fatal: Initate Mongo replica set failed." @@ -96,19 +96,19 @@ main() { prepare_console_config - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml -c ${COMPOSE_FILE_PATH}/docker-compose.stack-0.yml $openhim_dev_compose_param instant" "Failed to create stack-0 openhim core/console" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml -c ${COMPOSE_FILE_PATH}/docker-compose.stack-0.yml $openhim_dev_compose_param --with-registry-auth instant" "Failed to create stack-0 openhim core/console" - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.await-helper.yml instant" "Failed to deploy await-helper" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.await-helper.yml --with-registry-auth instant" "Failed to deploy await-helper" log info "Waiting to give OpenHIM Core time to start up before OpenHIM Console run" verify_core - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml -c ${COMPOSE_FILE_PATH}/docker-compose.stack-1.yml $openhim_dev_compose_param instant" "Failed to create stack-1 openhim core/console" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml -c ${COMPOSE_FILE_PATH}/docker-compose.stack-1.yml $openhim_dev_compose_param --with-registry-auth instant" "Failed to create stack-1 openhim core/console" - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to deploy config importer" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to deploy config importer" log info "Waiting to give core config importer time to run before cleaning up service" - + config::remove_config_importer interoperability-layer-openhim-config-importer # Ensure config importer is removed @@ -121,11 +121,11 @@ main() { config::set_config_digests "$COMPOSE_FILE_PATH"/docker-compose.yml config::set_config_digests "$COMPOSE_FILE_PATH"/importer/docker-compose.config.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose-mongo.yml $mongo_cluster_compose_param $mongo_dev_compose_param instant" "Failed to deploy mongo" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose-mongo.yml $mongo_cluster_compose_param $mongo_dev_compose_param --with-registry-auth instant" "Failed to deploy mongo" verify_mongos prepare_console_config - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml -c ${COMPOSE_FILE_PATH}/docker-compose.stack-1.yml $openhim_dev_compose_param instant" "Failed to create stack-1 openhim core/console" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml -c ${COMPOSE_FILE_PATH}/docker-compose.stack-1.yml $openhim_dev_compose_param --with-registry-auth instant" "Failed to create stack-1 openhim core/console" log info "Removing stale configs..." config::remove_stale_service_configs "$COMPOSE_FILE_PATH"/docker-compose.yml "openhim" diff --git a/job-scheduler-ofelia/swarm.sh b/job-scheduler-ofelia/swarm.sh index 772a69b7..9564385d 100644 --- a/job-scheduler-ofelia/swarm.sh +++ b/job-scheduler-ofelia/swarm.sh @@ -24,7 +24,7 @@ main() { config::substitute_env_vars "${COMPOSE_FILE_PATH}"/config.ini config::set_config_digests "${COMPOSE_FILE_PATH}"/docker-compose.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml instant" "Failed to deploy Job Scheduler Ofelia, does your .env file include all environment variables in your config.ini file?" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml --with-registry-auth instant" "Failed to deploy Job Scheduler Ofelia, does your .env file include all environment variables in your config.ini file?" elif [[ "${ACTION}" == "down" ]]; then try "docker service scale instant_job-scheduler-ofelia=0" "Failed to scale down job-scheduler-ofelia" elif [[ "${ACTION}" == "destroy" ]]; then diff --git a/kafka-mapper-consumer/swarm.sh b/kafka-mapper-consumer/swarm.sh index 50f58356..4ec63449 100755 --- a/kafka-mapper-consumer/swarm.sh +++ b/kafka-mapper-consumer/swarm.sh @@ -18,7 +18,7 @@ readonly ROOT_PATH main() { if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then config::set_config_digests "${COMPOSE_FILE_PATH}"/docker-compose.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml instant" "Failed to deploy Kafka Mapper Consumer" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml --with-registry-auth instant" "Failed to deploy Kafka Mapper Consumer" config::remove_stale_service_configs "${COMPOSE_FILE_PATH}"/docker-compose.yml "kafka-mapper-consumer" elif [[ "${ACTION}" == "down" ]]; then diff --git a/kafka-unbundler-consumer/swarm.sh b/kafka-unbundler-consumer/swarm.sh index 56e58573..e4803e3c 100755 --- a/kafka-unbundler-consumer/swarm.sh +++ b/kafka-unbundler-consumer/swarm.sh @@ -16,7 +16,7 @@ readonly ROOT_PATH main() { if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml instant" "Failed to deploy Kafka Unbundler Consumer" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml --with-registry-auth instant" "Failed to deploy Kafka Unbundler Consumer" elif [[ "${ACTION}" == "down" ]]; then try "docker service scale instant_kafka-unbundler-consumer=0" "Failed to scale down kafka-unbundler-consumer" diff --git a/message-bus-helper-hapi-proxy/swarm.sh b/message-bus-helper-hapi-proxy/swarm.sh index e163de40..b5cf5330 100644 --- a/message-bus-helper-hapi-proxy/swarm.sh +++ b/message-bus-helper-hapi-proxy/swarm.sh @@ -14,15 +14,15 @@ ROOT_PATH="${COMPOSE_FILE_PATH}/.." if [ "${ACTION}" == "init" ]; then if [ "${MODE}" == "dev" ]; then - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml instant" "Failed to deploy hapi-proxy" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml --with-registry-auth instant" "Failed to deploy hapi-proxy" else - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml -c ${COMPOSE_FILE_PATH}/docker-compose.prod.yml instant" "Failed to deploy hapi-proxy" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml -c ${COMPOSE_FILE_PATH}/docker-compose.prod.yml --with-registry-auth instant" "Failed to deploy hapi-proxy" fi elif [ "${ACTION}" == "up" ]; then if [ "${MODE}" == "dev" ]; then - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml instant" "Failed to deploy hapi-proxy" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml --with-registry-auth instant" "Failed to deploy hapi-proxy" else - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml -c ${COMPOSE_FILE_PATH}/docker-compose.prod.yml instant" "Failed to deploy hapi-proxy" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml -c ${COMPOSE_FILE_PATH}/docker-compose.prod.yml --with-registry-auth instant" "Failed to deploy hapi-proxy" fi elif [ "${ACTION}" == "down" ]; then try "docker service scale instant_hapi-proxy=0" "Failed to scale down hapi-proxy" diff --git a/message-bus-kafka/swarm.sh b/message-bus-kafka/swarm.sh index ae033a07..aa0be7a3 100755 --- a/message-bus-kafka/swarm.sh +++ b/message-bus-kafka/swarm.sh @@ -13,7 +13,6 @@ ROOT_PATH="${COMPOSE_FILE_PATH}/.." . "${ROOT_PATH}/utils/docker-utils.sh" . "${ROOT_PATH}/utils/log.sh" - if [[ $STATEFUL_NODES == "cluster" ]]; then log info "Running Message Bus Kafka package in Cluster node mode" kafkaClusterComposeParam="-c ${COMPOSE_FILE_PATH}/docker-compose.cluster.yml" @@ -33,11 +32,11 @@ fi if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then config::set_config_digests "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $kafkaClusterComposeParam $kafkaDevComposeParam instant" "Failed to deploy Message Bus Kafka" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $kafkaClusterComposeParam $kafkaDevComposeParam --with-registry-auth instant" "Failed to deploy Message Bus Kafka" config::await_service_running "kafka" "${COMPOSE_FILE_PATH}"/docker-compose.await-helper.yml "${KAFKA_INSTANCES}" - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to deploy Message Bus Kafka" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to deploy Message Bus Kafka" config::remove_stale_service_configs "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml "ethiopia" config::remove_config_importer message-bus-kafka-config-importer diff --git a/reverse-proxy-nginx/swarm.sh b/reverse-proxy-nginx/swarm.sh index bc1757ad..0e0b74fb 100755 --- a/reverse-proxy-nginx/swarm.sh +++ b/reverse-proxy-nginx/swarm.sh @@ -31,7 +31,7 @@ main() { config::generate_service_configs reverse-proxy-nginx /etc/nginx/conf.d "${COMPOSE_FILE_PATH}/package-conf-insecure" "${COMPOSE_FILE_PATH}" nginx nginx_temp_compose_param="-c ${COMPOSE_FILE_PATH}/docker-compose.tmp.yml" - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $nginx_temp_compose_param instant" "Failed to deploy nginx" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $nginx_temp_compose_param --with-registry-auth instant" "Failed to deploy nginx" if [ "${INSECURE_PORTS}" != "" ]; then IFS='-' read -ra PORTS <<<"$INSECURE_PORTS" @@ -62,7 +62,7 @@ main() { config::generate_service_configs reverse-proxy-nginx /etc/nginx/conf.d "${COMPOSE_FILE_PATH}/package-conf-secure" "${COMPOSE_FILE_PATH}" nginx nginx_temp_compose_param="-c ${COMPOSE_FILE_PATH}/docker-compose.tmp.yml" - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $nginx_temp_compose_param instant" "Failed to deploy nginx" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.yml $nginx_temp_compose_param --with-registry-auth instant" "Failed to deploy nginx" local domain_args=() if [ -n "$SUBDOMAINS" ]; then From 490b38bc0f36dc961f9f45680f6d76d094ac9a14 Mon Sep 17 00:00:00 2001 From: mark-labuschagne Date: Fri, 25 Nov 2022 11:05:28 +0200 Subject: [PATCH 2/7] register sync/async channels for JeMPI PLAT-623 --- .../openhim/docker-compose.config.yml | 33 ++++++ .../importer/openhim/openhim-import.json | 106 ++++++++++++++++++ .../importer/openhim/openhimConfig.js | 54 +++++++++ client-registry-jempi/package-metadata.json | 5 +- client-registry-jempi/swarm.sh | 16 +++ 5 files changed, 212 insertions(+), 2 deletions(-) create mode 100644 client-registry-jempi/importer/openhim/docker-compose.config.yml create mode 100644 client-registry-jempi/importer/openhim/openhim-import.json create mode 100644 client-registry-jempi/importer/openhim/openhimConfig.js diff --git a/client-registry-jempi/importer/openhim/docker-compose.config.yml b/client-registry-jempi/importer/openhim/docker-compose.config.yml new file mode 100644 index 00000000..af000aa9 --- /dev/null +++ b/client-registry-jempi/importer/openhim/docker-compose.config.yml @@ -0,0 +1,33 @@ +version: '3.9' + +services: + jempi-openhim-config-importer: + image: node:erbium-alpine + deploy: + restart_policy: + condition: none + environment: + OPENHIM_CORE_SERVICE_NAME: openhim-core + OPENHIM_MEDIATOR_API_PORT: 8080 + OPENHIM_API_USERNAME: root@openhim.org + OPENHIM_API_PASSWORD: ${JEMPI_OPENHIM_PASSWORD} + NODE_TLS_REJECT_UNAUTHORIZED: 0 + command: sh -c "node openhimConfig.js" + configs: + - source: openhim-config-importer-openhimConfig.js + target: /openhimConfig.js + - source: openhim-config-importer-openhim-import.json + target: /openhim-import.json + +configs: + openhim-config-importer-openhimConfig.js: + file: ./openhimConfig.js + name: openhim-config-importer-openhimConfig.js-${openhim_config_importer_openhimConfig_js_DIGEST:?err} + labels: + name: openhim + openhim-config-importer-openhim-import.json: + file: ./openhim-import.json + name: openhim-config-importer-openhim-import.json-${openhim_config_importer_openhim_import_js_DIGEST:?err} + labels: + name: openhim + diff --git a/client-registry-jempi/importer/openhim/openhim-import.json b/client-registry-jempi/importer/openhim/openhim-import.json new file mode 100644 index 00000000..c1439d7b --- /dev/null +++ b/client-registry-jempi/importer/openhim/openhim-import.json @@ -0,0 +1,106 @@ +{ + "Channels": [ + { + "methods": ["POST"], + "type": "http", + "allow": ["instant"], + "whitelist": [], + "authType": "private", + "matchContentTypes": [], + "properties": [], + "txViewAcl": [], + "txViewFullAcl": [], + "txRerunAcl": [], + "status": "enabled", + "rewriteUrls": false, + "addAutoRewriteRules": true, + "autoRetryEnabled": false, + "autoRetryPeriodMinutes": 60, + "routes": [ + { + "type": "http", + "status": "enabled", + "forwardAuthHeader": false, + "name": "JeMPI Sync Receiver", + "secured": false, + "host": "jempi-sync-reciever", + "port": 50000, + "path": "", + "pathTransform": "", + "primary": true, + "username": "", + "password": "" + } + ], + "requestBody": true, + "responseBody": true, + "rewriteUrlsConfig": [], + "name": "JeMPI Sync Receiver", + "urlPattern": "^/fhir/Patient.*$", + "priority": 10, + "matchContentRegex": null, + "matchContentXpath": null, + "matchContentValue": null, + "matchContentJson": null, + "pollingSchedule": null, + "tcpHost": null, + "tcpPort": null, + "updatedBy": { + "id": "605c8ddd9e66da001494935e", + "name": "Super User" + }, + "alerts": [] + }, + { + "methods": ["POST"], + "type": "http", + "allow": ["instant"], + "whitelist": [], + "authType": "private", + "matchContentTypes": [], + "properties": [], + "txViewAcl": [], + "txViewFullAcl": [], + "txRerunAcl": [], + "status": "enabled", + "rewriteUrls": false, + "addAutoRewriteRules": true, + "autoRetryEnabled": false, + "autoRetryPeriodMinutes": 60, + "routes": [ + { + "type": "http", + "status": "enabled", + "forwardAuthHeader": false, + "name": "JeMPI Async Receiver", + "secured": false, + "host": "jempi-async-reciever", + "port": 50000, + "path": "", + "pathTransform": "", + "primary": true, + "username": "", + "password": "" + } + ], + "requestBody": true, + "responseBody": true, + "rewriteUrlsConfig": [], + "name": "JeMPI Async Receiver", + "urlPattern": "^/csv/?$", + "priority": 1, + "matchContentRegex": null, + "matchContentXpath": null, + "matchContentValue": null, + "matchContentJson": null, + "pollingSchedule": null, + "tcpHost": null, + "tcpPort": null, + "updatedBy": { + "id": "605c8ddd9e66da001494935e", + "name": "Super User" + }, + "alerts": [] + } + ] +} diff --git a/client-registry-jempi/importer/openhim/openhimConfig.js b/client-registry-jempi/importer/openhim/openhimConfig.js new file mode 100644 index 00000000..4932ef06 --- /dev/null +++ b/client-registry-jempi/importer/openhim/openhimConfig.js @@ -0,0 +1,54 @@ +'use strict' + +const fs = require('fs') +const https = require('https') +const path = require('path') + +const OPENHIM_CORE_SERVICE_NAME = process.env.OPENHIM_CORE_SERVICE_NAME || 'openhim-core' +const OPENHIM_API_PASSWORD = + process.env.OPENHIM_API_PASSWORD || 'openhim-password' +const OPENHIM_MEDIATOR_API_PORT = process.env.OPENHIM_MEDIATOR_API_PORT || 8080 +const OPENHIM_API_USERNAME = + process.env.OPENHIM_API_USERNAME || 'root@openhim.org' + +const authHeader = new Buffer.from( + `${OPENHIM_API_USERNAME}:${OPENHIM_API_PASSWORD}` +).toString('base64') + +const jsonData = JSON.parse( + fs.readFileSync(path.resolve(__dirname, 'openhim-import.json')) +) + +const data = JSON.stringify(jsonData) + +const options = { + protocol: 'https:', + hostname: OPENHIM_CORE_SERVICE_NAME, + port: OPENHIM_MEDIATOR_API_PORT, + path: '/metadata', + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Content-Length': data.length, + Authorization: `Basic ${authHeader}` + } +} + +const req = https.request(options, res => { + if (res.statusCode == 401) { + throw new Error(`Incorrect OpenHIM API credentials`) + } + + if (res.statusCode != 201) { + throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`) + } + + console.log('Successfully Imported OpenHIM Config') +}) + +req.on('error', error => { + console.error('Failed to import OpenHIM config: ', error) +}) + +req.write(data) +req.end() diff --git a/client-registry-jempi/package-metadata.json b/client-registry-jempi/package-metadata.json index 67cb5994..a82a1bda 100644 --- a/client-registry-jempi/package-metadata.json +++ b/client-registry-jempi/package-metadata.json @@ -4,7 +4,7 @@ "description": "A patient matching and deduplicater for the platform", "type": "infrastructure", "version": "0.0.1", - "dependencies": [], + "dependencies": ["interoperability-layer-openhim"], "environmentVariables": { "STATEFUL_NODES": "single", "JEMPI_KAFKA_01_MEMORY_LIMIT": "3G", @@ -49,6 +49,7 @@ "JEMPI_CONTROLLER_IMAGE_TAG": "0.1.0", "JEMPI_EM_CALCULATOR_IMAGE_TAG": "0.1.0", "JEMPI_LINKER_IMAGE_TAG": "0.1.0", - "JEMPI_API_IMAGE_TAG": "0.1.0" + "JEMPI_API_IMAGE_TAG": "0.1.0", + "JEMPI_OPENHIM_PASSWORD": "instant101" } } diff --git a/client-registry-jempi/swarm.sh b/client-registry-jempi/swarm.sh index 6b301b1c..02d34518 100644 --- a/client-registry-jempi/swarm.sh +++ b/client-registry-jempi/swarm.sh @@ -110,6 +110,19 @@ main() { docker::await_service_ready jempi-api + if docker service ps -q instant_openhim-core &>/dev/null; then + config::set_config_digests "${COMPOSE_FILE_PATH}"/importer/openhim/docker-compose.config.yml + + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/openhim/docker-compose.config.yml instant" "Failed to deploy jempi-openhim-config-importer" + + log info "Waiting to give JeMPI Openhim config importer time to run before cleaning up service" + + config::remove_config_importer jempi-openhim-config-importer + config::await_service_removed instant_jempi-openhim-config-importer + else + log warn "Service 'interoperability-layer-openhim' does not appear to running... skipping configuring of async/sync JeMPI channels" + fi + docker::deploy_sanity "${service_names[@]}" elif [[ "${ACTION}" == "down" ]]; then log info "Scaling down client-registry-jempi" @@ -124,6 +137,9 @@ main() { docker::service_destroy "$service_name" done + docker::service_destroy jempi-kafka-config-importer + docker::service_destroy jempi-openhim-config-importer + docker::try_remove_volume jempi-kafka-01-data docker::try_remove_volume jempi-kafka-02-data docker::try_remove_volume jempi-kafka-03-data From e020f1ca8620a7506666282dfb24127e62edd58f Mon Sep 17 00:00:00 2001 From: mark-labuschagne Date: Fri, 25 Nov 2022 15:40:45 +0200 Subject: [PATCH 3/7] added registry auth flags to incoming services PLAT-524 --- client-registry-jempi/swarm.sh | 8 ++++---- mpi-mediator/swarm.sh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client-registry-jempi/swarm.sh b/client-registry-jempi/swarm.sh index 703f22e0..f7db6cd2 100644 --- a/client-registry-jempi/swarm.sh +++ b/client-registry-jempi/swarm.sh @@ -36,19 +36,19 @@ main() { fi if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafka.yml instant" "Failed to deploy Client Registry - JeMPI" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafka.yml --with-registry-auth instant" "Failed to deploy Client Registry - JeMPI" docker::await_service_ready jempi-kafka-01 docker::await_service_ready jempi-kafka-02 docker::await_service_ready jempi-kafka-03 - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafdrop.yml $kafdrop_dev_compose_param instant" "Failed to deploy jempi-Kafdrop" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafdrop.yml $kafdrop_dev_compose_param --with-registry-auth instant" "Failed to deploy jempi-Kafdrop" docker::await_service_ready jempi-kafdrop config::set_config_digests "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml instant" "Failed to deploy jempi-kafka-config-importer" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/importer/docker-compose.config.yml --with-registry-auth instant" "Failed to deploy jempi-kafka-config-importer" log info "Waiting to give JeMPI Kafka config importer time to run before cleaning up service" @@ -57,7 +57,7 @@ main() { config::remove_stale_service_configs "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml "jempi-kafka" - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.dgraph.yml $dgraph_dev_compose_param $dgraph_cluster_compose_param instant" "Failed to deploy Client Registry - JeMPI" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.dgraph.yml $dgraph_dev_compose_param $dgraph_cluster_compose_param --with-registry-auth instant" "Failed to deploy Client Registry - JeMPI" docker::await_service_ready jempi-zero-01 diff --git a/mpi-mediator/swarm.sh b/mpi-mediator/swarm.sh index 4dd97d37..153a6e23 100644 --- a/mpi-mediator/swarm.sh +++ b/mpi-mediator/swarm.sh @@ -35,11 +35,11 @@ main() { if [[ "$ACTION" == "init" ]]; then log info "Deploying MPI-Mediator..." - try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.yml $mpi_mediator_cluster_compose_param $mpi_mediator_dev_compose_param instant" "Failed to deploy mpi-mediator" + try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.yml $mpi_mediator_cluster_compose_param $mpi_mediator_dev_compose_param --with-registry-auth instant" "Failed to deploy mpi-mediator" overwrite "Deploying MPI-Mediator... Done" elif [[ "$ACTION" == "up" ]]; then log info "Updating MPI-Mediator..." - try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.yml $mpi_mediator_cluster_compose_param $mpi_mediator_dev_compose_param instant" "Failed to stand up mpi-mediator" + try "docker stack deploy -c $COMPOSE_FILE_PATH/docker-compose.yml $mpi_mediator_cluster_compose_param $mpi_mediator_dev_compose_param --with-registry-auth instant" "Failed to stand up mpi-mediator" overwrite "Updating MPI-Mediator... Done" elif [[ "$ACTION" == "down" ]]; then log info "Scaling MPI-Mediator down..." From 85f36e59b8302953cac58b68cd30b5c7c7e02864 Mon Sep 17 00:00:00 2001 From: Mark-Labuschagne <78809924+Mark-Labuschagne@users.noreply.github.com> Date: Tue, 29 Nov 2022 12:04:44 +0200 Subject: [PATCH 4/7] Update client-registry-jempi/importer/openhim/openhimConfig.js Co-authored-by: Nour Borgi <48720958+nour-borgi@users.noreply.github.com> --- client-registry-jempi/importer/openhim/openhimConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client-registry-jempi/importer/openhim/openhimConfig.js b/client-registry-jempi/importer/openhim/openhimConfig.js index 4932ef06..ba86cd8b 100644 --- a/client-registry-jempi/importer/openhim/openhimConfig.js +++ b/client-registry-jempi/importer/openhim/openhimConfig.js @@ -43,7 +43,7 @@ const req = https.request(options, res => { throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`) } - console.log('Successfully Imported OpenHIM Config') + console.log('Successfully imported OpenHIM config') }) req.on('error', error => { From d83242490e3ba3affb02f0bfade049783a02613c Mon Sep 17 00:00:00 2001 From: Mark-Labuschagne <78809924+Mark-Labuschagne@users.noreply.github.com> Date: Tue, 29 Nov 2022 12:04:58 +0200 Subject: [PATCH 5/7] Update client-registry-jempi/swarm.sh Co-authored-by: Nour Borgi <48720958+nour-borgi@users.noreply.github.com> --- client-registry-jempi/swarm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client-registry-jempi/swarm.sh b/client-registry-jempi/swarm.sh index 02d34518..7080c479 100644 --- a/client-registry-jempi/swarm.sh +++ b/client-registry-jempi/swarm.sh @@ -120,7 +120,7 @@ main() { config::remove_config_importer jempi-openhim-config-importer config::await_service_removed instant_jempi-openhim-config-importer else - log warn "Service 'interoperability-layer-openhim' does not appear to running... skipping configuring of async/sync JeMPI channels" + log warn "Service 'interoperability-layer-openhim' does not appear to be running... skipping configuring of async/sync JeMPI channels" fi docker::deploy_sanity "${service_names[@]}" From 524e64a1204df02d4de6d1774133653cb67a08e1 Mon Sep 17 00:00:00 2001 From: mark-labuschagne Date: Tue, 29 Nov 2022 12:12:29 +0200 Subject: [PATCH 6/7] removed obselete defaults the defaults there would never be accessed, and should always have set values in their docker-compose files PLAT-623 --- client-registry-jempi/importer/openhim/openhimConfig.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client-registry-jempi/importer/openhim/openhimConfig.js b/client-registry-jempi/importer/openhim/openhimConfig.js index ba86cd8b..8dd6ef1f 100644 --- a/client-registry-jempi/importer/openhim/openhimConfig.js +++ b/client-registry-jempi/importer/openhim/openhimConfig.js @@ -4,12 +4,12 @@ const fs = require('fs') const https = require('https') const path = require('path') -const OPENHIM_CORE_SERVICE_NAME = process.env.OPENHIM_CORE_SERVICE_NAME || 'openhim-core' +const OPENHIM_CORE_SERVICE_NAME = process.env.OPENHIM_CORE_SERVICE_NAME const OPENHIM_API_PASSWORD = - process.env.OPENHIM_API_PASSWORD || 'openhim-password' -const OPENHIM_MEDIATOR_API_PORT = process.env.OPENHIM_MEDIATOR_API_PORT || 8080 + process.env.OPENHIM_API_PASSWORD +const OPENHIM_MEDIATOR_API_PORT = process.env.OPENHIM_MEDIATOR_API_PORT const OPENHIM_API_USERNAME = - process.env.OPENHIM_API_USERNAME || 'root@openhim.org' + process.env.OPENHIM_API_USERNAME const authHeader = new Buffer.from( `${OPENHIM_API_USERNAME}:${OPENHIM_API_PASSWORD}` From 6093a508bd86244d6dde86a5e920d17c46301f54 Mon Sep 17 00:00:00 2001 From: mark-labuschagne Date: Tue, 29 Nov 2022 12:20:12 +0200 Subject: [PATCH 7/7] linting --- .../importer/openhim/openhimConfig.js | 62 +++++++++---------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/client-registry-jempi/importer/openhim/openhimConfig.js b/client-registry-jempi/importer/openhim/openhimConfig.js index 8dd6ef1f..b475407d 100644 --- a/client-registry-jempi/importer/openhim/openhimConfig.js +++ b/client-registry-jempi/importer/openhim/openhimConfig.js @@ -1,54 +1,52 @@ -'use strict' +"use strict"; -const fs = require('fs') -const https = require('https') -const path = require('path') +const fs = require("fs"); +const https = require("https"); +const path = require("path"); -const OPENHIM_CORE_SERVICE_NAME = process.env.OPENHIM_CORE_SERVICE_NAME -const OPENHIM_API_PASSWORD = - process.env.OPENHIM_API_PASSWORD -const OPENHIM_MEDIATOR_API_PORT = process.env.OPENHIM_MEDIATOR_API_PORT -const OPENHIM_API_USERNAME = - process.env.OPENHIM_API_USERNAME +const OPENHIM_CORE_SERVICE_NAME = process.env.OPENHIM_CORE_SERVICE_NAME; +const OPENHIM_API_PASSWORD = process.env.OPENHIM_API_PASSWORD; +const OPENHIM_MEDIATOR_API_PORT = process.env.OPENHIM_MEDIATOR_API_PORT; +const OPENHIM_API_USERNAME = process.env.OPENHIM_API_USERNAME; const authHeader = new Buffer.from( `${OPENHIM_API_USERNAME}:${OPENHIM_API_PASSWORD}` -).toString('base64') +).toString("base64"); const jsonData = JSON.parse( - fs.readFileSync(path.resolve(__dirname, 'openhim-import.json')) -) + fs.readFileSync(path.resolve(__dirname, "openhim-import.json")) +); -const data = JSON.stringify(jsonData) +const data = JSON.stringify(jsonData); const options = { - protocol: 'https:', + protocol: "https:", hostname: OPENHIM_CORE_SERVICE_NAME, port: OPENHIM_MEDIATOR_API_PORT, - path: '/metadata', - method: 'POST', + path: "/metadata", + method: "POST", headers: { - 'Content-Type': 'application/json', - 'Content-Length': data.length, - Authorization: `Basic ${authHeader}` - } -} + "Content-Type": "application/json", + "Content-Length": data.length, + Authorization: `Basic ${authHeader}`, + }, +}; -const req = https.request(options, res => { +const req = https.request(options, (res) => { if (res.statusCode == 401) { - throw new Error(`Incorrect OpenHIM API credentials`) + throw new Error(`Incorrect OpenHIM API credentials`); } if (res.statusCode != 201) { - throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`) + throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`); } - console.log('Successfully imported OpenHIM config') -}) + console.log("Successfully imported OpenHIM config"); +}); -req.on('error', error => { - console.error('Failed to import OpenHIM config: ', error) -}) +req.on("error", (error) => { + console.error("Failed to import OpenHIM config: ", error); +}); -req.write(data) -req.end() +req.write(data); +req.end();