Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ES support password config #87

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,27 +166,27 @@ 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://<broker-host-name>" -db-host "<postgres-host-name>" -db-port 5432 -db-name "<postgres-db-name>" -db-user "<postgres-db-user>" -db-password "<postgres-db-password> server migrate"
./compass -elasticsearch-brokers "http://<broker-host-name>" -elasticsearch-password "" -db-host "<postgres-host-name>" -db-port 5432 -db-name "<postgres-db-name>" -db-user "<postgres-db-user>" -db-password "<postgres-db-password> server migrate"
```

## Serving locally

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://<broker-host-name>" -db-host "<postgres-host-name>" -db-port 5432 -db-name "<postgres-db-name>" -db-user "<postgres-db-user>" -db-password "<postgres-db-password> server start"
./compass -elasticsearch-brokers "http://<broker-host-name>" -elasticsearch-password "" -db-host "<postgres-host-name>" -db-port 5432 -db-name "<postgres-db-name>" -db-user "<postgres-db-user>" -db-password "<postgres-db-password> server start"
```

## Running tests
Expand Down
1 change: 1 addition & 0 deletions compass.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ newrelic:

elasticsearch:
brokers: http://localhost:9200
password:
request_timeout: 10s

db:
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ log_level: info # debug|info|warning|error|fatal

elasticsearch:
brokers: http://localhost:9200 #required
password:

db:
host: localhost #required
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -238,6 +240,7 @@ app:

secretConfig: {}
# COMPASS_ELASTICSEARCH_BROKERS: ~
# COMPASS_ELASTICSEARCH_PASSWORD: ~
# COMPASS_NEWRELIC_LICENSEKEY: ~
# COMPASS_DB_HOST: ~
# COMPASS_DB_PORT: 5432
Expand Down
2 changes: 2 additions & 0 deletions internal/store/elasticsearch/es.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (

type Config struct {
Brokers string `mapstructure:"brokers" default:"http://localhost:9200"`
Password string `mapstructure:"password" default:""`
haveiss marked this conversation as resolved.
Show resolved Hide resolved
RequestTimeout time.Duration `mapstructure:"request_timeout" default:"10s"`
}

Expand Down Expand Up @@ -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,
Expand Down