diff --git a/README.md b/README.md index 79c2121..3acedcf 100644 --- a/README.md +++ b/README.md @@ -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" diff --git a/cmd/observation-encoder/main.go b/cmd/observation-encoder/main.go index 28a4b87..284d559 100644 --- a/cmd/observation-encoder/main.go +++ b/cmd/observation-encoder/main.go @@ -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 { @@ -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 { diff --git a/internal/app/app.go b/internal/app/app.go index a0333dc..5a63628 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -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 } @@ -26,8 +24,6 @@ type appHandle struct { log common.Logger natsHandle nats libtapirHandle libtapir - address string - port string exitCh chan<- common.Exit pm } @@ -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