From 9e25e52497c59f3c26b52db1be0f573a336a3257 Mon Sep 17 00:00:00 2001 From: oxypomme Date: Wed, 7 Aug 2024 11:13:15 +0200 Subject: [PATCH] feat: support connection to elastic with url url will take precedence over host/port when provided --- src/graphql/config/custom-environment-variables.json | 1 + src/graphql/config/default.json | 1 + src/graphql/lib/services/elastic.js | 2 +- src/health/config/custom-environment-variables.json | 1 + src/health/config/default.json | 1 + src/health/lib/services/elastic.js | 2 +- src/update/config/custom-environment-variables.json | 1 + src/update/config/default.json | 1 + src/update/lib/services/elastic.js | 2 +- 9 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/graphql/config/custom-environment-variables.json b/src/graphql/config/custom-environment-variables.json index 25340603..e2ab756e 100644 --- a/src/graphql/config/custom-environment-variables.json +++ b/src/graphql/config/custom-environment-variables.json @@ -7,6 +7,7 @@ "password": "REDIS_PASSWORD" }, "elasticsearch": { + "url": "ELASTICSEARCH_URL", "host": "ELASTICSEARCH_HOSTS", "port": "ELASTICSEARCH_PORT", "user": "ELASTICSEARCH_USERNAME", diff --git a/src/graphql/config/default.json b/src/graphql/config/default.json index f57ad5e9..3abdb560 100644 --- a/src/graphql/config/default.json +++ b/src/graphql/config/default.json @@ -7,6 +7,7 @@ "password": "changeme" }, "elasticsearch": { + "url": "", "host": "http://elastic", "port": 9200, "user": "elastic", diff --git a/src/graphql/lib/services/elastic.js b/src/graphql/lib/services/elastic.js index c493010b..1a88332e 100644 --- a/src/graphql/lib/services/elastic.js +++ b/src/graphql/lib/services/elastic.js @@ -27,7 +27,7 @@ if (isProd) { const elasticClient = new Client({ node: { - url: new URL(`${elasticsearch.host}:${elasticsearch.port}`), + url: new URL(elasticsearch.url || `${elasticsearch.host}:${elasticsearch.port}`), auth: { username: elasticsearch.user, password: elasticsearch.password, diff --git a/src/health/config/custom-environment-variables.json b/src/health/config/custom-environment-variables.json index 056c5fc9..6f2d41d9 100644 --- a/src/health/config/custom-environment-variables.json +++ b/src/health/config/custom-environment-variables.json @@ -6,6 +6,7 @@ "apikeyHost": "APIKEY_HOST", "mailHost": "MAIL_HOST", "elasticsearch": { + "url": "ELASTICSEARCH_URL", "host": "ELASTICSEARCH_HOSTS", "port": "ELASTICSEARCH_PORT", "user": "ELASTICSEARCH_USERNAME", diff --git a/src/health/config/default.json b/src/health/config/default.json index 21a434f9..89d25e74 100644 --- a/src/health/config/default.json +++ b/src/health/config/default.json @@ -6,6 +6,7 @@ "apikeyHost": "http://apikey:3000", "mailHost": "http://mail:3000", "elasticsearch": { + "url": "", "host": "http://elastic", "port": 9200, "user": "elastic", diff --git a/src/health/lib/services/elastic.js b/src/health/lib/services/elastic.js index f4b1dfb0..681e795a 100644 --- a/src/health/lib/services/elastic.js +++ b/src/health/lib/services/elastic.js @@ -34,7 +34,7 @@ async function pingElasticWithClient() { const elasticClient = new Client({ node: { - url: new URL(`${elasticsearch.host}:${elasticsearch.port}`), + url: new URL(elasticsearch.url || `${elasticsearch.host}:${elasticsearch.port}`), auth: { username: elasticsearch.user, password: elasticsearch.password, diff --git a/src/update/config/custom-environment-variables.json b/src/update/config/custom-environment-variables.json index 6845e35f..16ca834b 100644 --- a/src/update/config/custom-environment-variables.json +++ b/src/update/config/custom-environment-variables.json @@ -10,6 +10,7 @@ "apikey": "MAIL_APIKEY" }, "elasticsearch": { + "url": "ELASTICSEARCH_URL", "host": "ELASTICSEARCH_HOSTS", "port": "ELASTICSEARCH_PORT", "user": "ELASTICSEARCH_USERNAME", diff --git a/src/update/config/default.json b/src/update/config/default.json index 93d3872a..fd5c8f38 100644 --- a/src/update/config/default.json +++ b/src/update/config/default.json @@ -10,6 +10,7 @@ "apikey": "changeme" }, "elasticsearch": { + "url": "", "host": "http://elastic", "port": 9200, "user": "elastic", diff --git a/src/update/lib/services/elastic.js b/src/update/lib/services/elastic.js index 1d32092f..7d1f8b4d 100644 --- a/src/update/lib/services/elastic.js +++ b/src/update/lib/services/elastic.js @@ -27,7 +27,7 @@ if (isProd) { const elasticClient = new Client({ node: { - url: new URL(`${elasticsearch.host}:${elasticsearch.port}`), + url: new URL(elasticsearch.url || `${elasticsearch.host}:${elasticsearch.port}`), auth: { username: elasticsearch.user, password: elasticsearch.password,