File tree Expand file tree Collapse file tree 3 files changed +9
-18
lines changed
Expand file tree Collapse file tree 3 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,6 @@ observation-encoder -config /path/to/config/file
1919# Sample config file
2020
2121``` toml
22- address = " 127.0.0.1"
23- port = " 10000"
24-
2522[cert ]
2623interval = 100
2724cert_dir = " /path/to/certs/dir"
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ import (
2121 "github.com/dnstapir/observation-encoder/internal/nats"
2222)
2323
24+ const c_ENVVAR_OVERRIDE_NATS_URL = "DNSTAPIR_NATS_URL"
25+
2426var commit = "BAD-BUILD"
2527
2628type conf struct {
@@ -105,6 +107,12 @@ func main() {
105107 log .Error ("Error creating nats log: %s" , err )
106108 }
107109
110+ envNatsUrl , overrideNatsUrl := os .LookupEnv (c_ENVVAR_OVERRIDE_NATS_URL )
111+ if overrideNatsUrl {
112+ mainConf .Nats .Url = envNatsUrl
113+ log .Info ("Overriding NATS url with environment variable '%s'" , c_ENVVAR_OVERRIDE_NATS_URL )
114+ }
115+
108116 mainConf .Nats .Log = natslog
109117 natsHandle , err := nats .Create (mainConf .Nats )
110118 if err != nil {
Original file line number Diff line number Diff line change @@ -14,9 +14,7 @@ const c_NATS_DELIM = common.NATS_DELIM
1414
1515type Conf struct {
1616 Log common.Logger
17- Debug bool `toml:"debug"`
18- Address string `toml:"address"`
19- Port string `toml:"port"`
17+ Debug bool `toml:"debug"`
2018 NatsHandle nats
2119 LibtapirHandle libtapir
2220}
@@ -26,8 +24,6 @@ type appHandle struct {
2624 log common.Logger
2725 natsHandle nats
2826 libtapirHandle libtapir
29- address string
30- port string
3127 exitCh chan <- common.Exit
3228 pm
3329}
@@ -67,17 +63,7 @@ func Create(conf Conf) (*appHandle, error) {
6763 return nil , common .ErrBadHandle
6864 }
6965
70- if conf .Address == "" {
71- return nil , common .ErrBadParam
72- }
73-
74- if conf .Port == "" {
75- return nil , common .ErrBadParam
76- }
77-
7866 a .log = conf .Log
79- a .address = conf .Address
80- a .port = conf .Port
8167 a .id = "main app"
8268 a .natsHandle = conf .NatsHandle
8369 a .libtapirHandle = conf .LibtapirHandle
You can’t perform that action at this time.
0 commit comments