Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ observation-encoder -config /path/to/config/file
# Sample config file

```toml
address = "127.0.0.1"
port = "10000"

[cert]
interval = 100
cert_dir = "/path/to/certs/dir"
Expand Down
8 changes: 8 additions & 0 deletions cmd/observation-encoder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/dnstapir/observation-encoder/internal/nats"
)

const c_ENVVAR_OVERRIDE_NATS_URL = "DNSTAPIR_NATS_URL"

var commit = "BAD-BUILD"

type conf struct {
Expand Down Expand Up @@ -105,6 +107,12 @@ func main() {
log.Error("Error creating nats log: %s", err)
}

envNatsUrl, overrideNatsUrl := os.LookupEnv(c_ENVVAR_OVERRIDE_NATS_URL)
if overrideNatsUrl {
mainConf.Nats.Url = envNatsUrl
log.Info("Overriding NATS url with environment variable '%s'", c_ENVVAR_OVERRIDE_NATS_URL)
}

mainConf.Nats.Log = natslog
natsHandle, err := nats.Create(mainConf.Nats)
if err != nil {
Expand Down
16 changes: 1 addition & 15 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const c_NATS_DELIM = common.NATS_DELIM

type Conf struct {
Log common.Logger
Debug bool `toml:"debug"`
Address string `toml:"address"`
Port string `toml:"port"`
Debug bool `toml:"debug"`
NatsHandle nats
LibtapirHandle libtapir
}
Expand All @@ -26,8 +24,6 @@ type appHandle struct {
log common.Logger
natsHandle nats
libtapirHandle libtapir
address string
port string
exitCh chan<- common.Exit
pm
}
Expand Down Expand Up @@ -67,17 +63,7 @@ func Create(conf Conf) (*appHandle, error) {
return nil, common.ErrBadHandle
}

if conf.Address == "" {
return nil, common.ErrBadParam
}

if conf.Port == "" {
return nil, common.ErrBadParam
}

a.log = conf.Log
a.address = conf.Address
a.port = conf.Port
a.id = "main app"
a.natsHandle = conf.NatsHandle
a.libtapirHandle = conf.LibtapirHandle
Expand Down