Skip to content

Commit

Permalink
fix: fix config path name and default
Browse files Browse the repository at this point in the history
  • Loading branch information
kianaza committed Jul 7, 2024
1 parent c0e7fa9 commit f36b1df
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You can deploy and use NATS Blackbox Exporter using Docker images or by building
### 1. Using Docker Image 📫
You can use pre-built Docker images from GitHub Container Registry (GHCR):
```bash
docker run -d -p 8080:8080 --name nats-blackbox-exporter -v ./setting/config.yaml:/app/setting/config.yaml:ro ghcr.io/snapp-incubator/nats-blackbox-exporter:<release-tag> -settings ./setting/config.yaml
docker run -d -p 8080:8080 --name nats-blackbox-exporter -v ./setting/config.yaml:/app/setting/config.yaml:ro ghcr.io/snapp-incubator/nats-blackbox-exporter:<release-tag> --configPath ./setting/config.yaml
```
and then pass environment variables as needed.

Expand All @@ -51,12 +51,12 @@ You can check the list of parameters with default values in the [config.example.

2. **Configuration File:**

Use a `config.yaml` file to specify configuration parameters. You can specify the path to the config file using the `-settings` flag.
Use a `config.yaml` file to specify configuration parameters. You can specify the path to the config file using the `--configPath` flag.

Example usage:

```bash
./nats-blackbox-exporter -settings /path/to/config.yaml
./nats-blackbox-exporter --configPath /path/to/config.yaml
```

Replace `/path/to/config.yaml` with the actual path to your configuration file.
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
// ExitFailure status code.
const ExitFailure = 1

var settingsPath string
var configPath string

func Execute() {
pflag.StringVar(&settingsPath, "settings", "/opt/nats-blackbox-exporter/settings.yml", "Path to settings file")
pflag.StringVar(&configPath, "configPath", "./config.yaml", "Path to config file")
pflag.Parse()

Check warning on line 20 in internal/cmd/root.go

View check run for this annotation

Codecov / codecov/patch

internal/cmd/root.go#L19-L20

Added lines #L19 - L20 were not covered by tests

cfg := config.New(settingsPath)
cfg := config.New(configPath)

Check warning on line 22 in internal/cmd/root.go

View check run for this annotation

Codecov / codecov/patch

internal/cmd/root.go#L22

Added line #L22 was not covered by tests

logger := logger.New(cfg.Logger)

Expand Down
6 changes: 3 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type (
)

// New reads configuration with koanf.
func New(settingsPath string) Config {
func New(configPath string) Config {

Check warning on line 34 in internal/config/config.go

View check run for this annotation

Codecov / codecov/patch

internal/config/config.go#L34

Added line #L34 was not covered by tests
var instance Config

k := koanf.New(".")
Expand All @@ -42,8 +42,8 @@ func New(settingsPath string) Config {
}

// load configuration from file
if err := k.Load(file.Provider(settingsPath), yaml.Parser()); err != nil {
log.Printf("error loading config.yaml from: %s", settingsPath)
if err := k.Load(file.Provider(configPath), yaml.Parser()); err != nil {
log.Printf("error loading config.yaml from: %s", configPath)

Check warning on line 46 in internal/config/config.go

View check run for this annotation

Codecov / codecov/patch

internal/config/config.go#L45-L46

Added lines #L45 - L46 were not covered by tests
}

// load environment variables
Expand Down

0 comments on commit f36b1df

Please sign in to comment.