Skip to content

Commit

Permalink
feat: add username
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Luthfi Fahlevi committed Nov 29, 2024
1 parent 1c65fce commit d468d1c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
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 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
$ docker run --rm --net compass_storage -p 8080:8080 -e ELASTICSEARCH_BROKERS=http://es:9200 -e ELASTICSEARCH_USERNAME= -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>" -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"
./compass -elasticsearch-brokers "http://<broker-host-name>" -elasticsearch-username "" -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 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
docker run --net compass_storage -p 8080:8080 -e ELASTICSEARCH_BROKERS=http://es:9200 -e ELASTICSEARCH_USERNAME= -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>" -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"
./compass -elasticsearch-brokers "http://<broker-host-name>" -elasticsearch-username "" -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
username:
password:
request_timeout: 10s

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
username:
password:

db:
Expand Down Expand Up @@ -68,6 +69,7 @@ See [configuration reference](./reference/configuration.md) for the list of all
```sh title=".env"
LOG_LEVEL=info
ELASTICSEARCH_BROKERS=http://localhost:9200
ELASTICSEARCH_USERNAME=
ELASTICSEARCH_PASSWORD=
DB_HOST=localhost
DB_PORT=5432
Expand Down Expand Up @@ -240,6 +242,7 @@ app:

secretConfig: {}
# COMPASS_ELASTICSEARCH_BROKERS: ~
# COMPASS_ELASTICSEARCH_USERNAME: ~
# COMPASS_ELASTICSEARCH_PASSWORD: ~
# COMPASS_NEWRELIC_LICENSEKEY: ~
# COMPASS_DB_HOST: ~
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"`
Username string `mapstructure:"username" default:""`
Password string `mapstructure:"password" default:""`
RequestTimeout time.Duration `mapstructure:"request_timeout" default:"10s"`
}
Expand Down Expand Up @@ -132,6 +133,7 @@ func NewClient(logger log.Logger, config Config, opts ...ClientOption) (*Client,
esClient, err := elasticsearch.NewClient(elasticsearch.Config{
Addresses: brokers,
Transport: nrelasticsearch.NewRoundTripper(nil),
Username: config.Username,
Password: config.Password,
// uncomment below code to debug request and response to elasticsearch
// Logger: &estransport.ColorLogger{
Expand Down

0 comments on commit d468d1c

Please sign in to comment.