From 33608a19c871a05c19645f2e9b907eb03a811645 Mon Sep 17 00:00:00 2001 From: Muhammad Luthfi Fahlevi Date: Fri, 29 Nov 2024 17:44:57 +0700 Subject: [PATCH] feat: separate drop uuid users column to another MR --- README.md | 8 ++++---- compass.yaml.example | 1 + docs/docs/configuration.md | 3 +++ internal/store/elasticsearch/es.go | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4ae8e75d..c4b90fa1 100644 --- a/README.md +++ b/README.md @@ -166,13 +166,13 @@ docker build . -t compass Before serving Compass app, we need to run the migration first. Run this docker command to migrate Compass. ```text -$ docker run --rm --net compass_storage -p 8080:8080 -e ELASTICSEARCH_BROKERS=http://es:9200 -e DB_HOST=postgres -e DB_PORT=5432 -e DB_NAME=compass -e DB_USER=compass -e DB_PASSWORD=compass_password gotocompany/compass compass server migrate +$ docker run --rm --net compass_storage -p 8080:8080 -e ELASTICSEARCH_BROKERS=http://es:9200 -e ELASTICSEARCH_PASSWORD= -e DB_HOST=postgres -e DB_PORT=5432 -e DB_NAME=compass -e DB_USER=compass -e DB_PASSWORD=compass_password gotocompany/compass compass server migrate ``` If you are using Compass binary, you can run this command. ```text -./compass -elasticsearch-brokers "http://" -db-host "" -db-port 5432 -db-name "" -db-user "" -db-password " server migrate" +./compass -elasticsearch-brokers "http://" -elasticsearch-password "" -db-host "" -db-port 5432 -db-name "" -db-user "" -db-password " server migrate" ``` ## Serving locally @@ -180,13 +180,13 @@ If you are using Compass binary, you can run this command. Once the migration has been done, Compass server can be started with this command. ```text -docker run --net compass_storage -p 8080:8080 -e ELASTICSEARCH_BROKERS=http://es:9200 -e DB_HOST=postgres -e DB_PORT=5432 -e DB_NAME=compass -e DB_USER=compass -e DB_PASSWORD=compass_password gotocompany/compass compass server start +docker run --net compass_storage -p 8080:8080 -e ELASTICSEARCH_BROKERS=http://es:9200 -e ELASTICSEARCH_PASSWORD= -e DB_HOST=postgres -e DB_PORT=5432 -e DB_NAME=compass -e DB_USER=compass -e DB_PASSWORD=compass_password gotocompany/compass compass server start ``` If you are using Compass binary, you can run this command. ```text -./compass -elasticsearch-brokers "http://" -db-host "" -db-port 5432 -db-name "" -db-user "" -db-password " server start" +./compass -elasticsearch-brokers "http://" -elasticsearch-password "" -db-host "" -db-port 5432 -db-name "" -db-user "" -db-password " server start" ``` ## Running tests diff --git a/compass.yaml.example b/compass.yaml.example index d12c1e2d..1c26b43b 100644 --- a/compass.yaml.example +++ b/compass.yaml.example @@ -29,6 +29,7 @@ newrelic: elasticsearch: brokers: http://localhost:9200 + password: request_timeout: 10s db: diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index e550aad4..ef07cf33 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -38,6 +38,7 @@ log_level: info # debug|info|warning|error|fatal elasticsearch: brokers: http://localhost:9200 #required + password: db: host: localhost #required @@ -67,6 +68,7 @@ See [configuration reference](./reference/configuration.md) for the list of all ```sh title=".env" LOG_LEVEL=info ELASTICSEARCH_BROKERS=http://localhost:9200 +ELASTICSEARCH_PASSWORD= DB_HOST=localhost DB_PORT=5432 DB_NAME=compass @@ -238,6 +240,7 @@ app: secretConfig: {} # COMPASS_ELASTICSEARCH_BROKERS: ~ + # COMPASS_ELASTICSEARCH_PASSWORD: ~ # COMPASS_NEWRELIC_LICENSEKEY: ~ # COMPASS_DB_HOST: ~ # COMPASS_DB_PORT: 5432 diff --git a/internal/store/elasticsearch/es.go b/internal/store/elasticsearch/es.go index 5014d905..cdcfb65f 100644 --- a/internal/store/elasticsearch/es.go +++ b/internal/store/elasticsearch/es.go @@ -28,6 +28,7 @@ const ( type Config struct { Brokers string `mapstructure:"brokers" default:"http://localhost:9200"` + Password string `mapstructure:"password" default:""` RequestTimeout time.Duration `mapstructure:"request_timeout" default:"10s"` } @@ -131,6 +132,7 @@ func NewClient(logger log.Logger, config Config, opts ...ClientOption) (*Client, esClient, err := elasticsearch.NewClient(elasticsearch.Config{ Addresses: brokers, Transport: nrelasticsearch.NewRoundTripper(nil), + Password: config.Password, // uncomment below code to debug request and response to elasticsearch // Logger: &estransport.ColorLogger{ // Output: os.Stdout,