Skip to content

Commit e85ae56

Browse files
committed
config: update lints for listen configuration
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
1 parent 9ab91df commit e85ae56

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

config/config.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ type Config struct {
4747
}
4848

4949
func (c *Config) validate(mode Mode) ([]Warning, error) {
50-
if c.HTTPListenAddr == "" {
51-
c.HTTPListenAddr = DefaultAddress
52-
}
5350
if c.Matcher.DisableUpdaters {
5451
c.Updaters.Sets = []string{}
5552
}
@@ -59,23 +56,25 @@ func (c *Config) validate(mode Mode) ([]Warning, error) {
5956
default:
6057
return nil, fmt.Errorf("unknown mode: %q", mode)
6158
}
62-
if _, _, err := net.SplitHostPort(c.HTTPListenAddr); err != nil {
63-
return nil, err
59+
if c.HTTPListenAddr != "" {
60+
if _, _, err := net.SplitHostPort(c.HTTPListenAddr); err != nil {
61+
return nil, err
62+
}
6463
}
6564
return c.lint()
6665
}
6766

6867
func (c *Config) lint() (ws []Warning, err error) {
69-
if c.HTTPListenAddr == "" {
68+
if c.HTTPListenAddr != "" {
7069
ws = append(ws, Warning{
71-
path: ".http_listen_addr",
72-
msg: `http listen address not provided, default will be used`,
70+
path: ".http_listen_addr",
71+
inner: fmt.Errorf(`configuration via $.api.v1 is preferred: %w`, ErrDeprecated),
7372
})
7473
}
75-
if c.IntrospectionAddr == "" {
74+
if c.IntrospectionAddr != "" {
7675
ws = append(ws, Warning{
77-
path: ".introspection_addr",
78-
msg: `introspection address not provided, default will be used`,
76+
path: ".introspection_addr",
77+
inner: fmt.Errorf(`configuration via $.introspection is preferred: %w`, ErrDeprecated),
7978
})
8079
}
8180
return ws, nil

config/lint_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ func ExampleLint() {
2727
}
2828
// Output:
2929
// error: <nil>
30-
// warning: http listen address not provided, default will be used (at $.http_listen_addr)
31-
// warning: introspection address not provided, default will be used (at $.introspection_addr)
3230
// warning: connection string is empty and no relevant environment variables found (at $.indexer.connstring)
3331
// warning: connection string is empty and no relevant environment variables found (at $.matcher.connstring)
3432
// warning: updater period is very aggressive: most sources are updated daily (at $.matcher.period)
3533
// warning: update garbage collection is off (at $.matcher.update_retention)
3634
// warning: connection string is empty and no relevant environment variables found (at $.notifier.connstring)
3735
// warning: interval is very fast: may result in increased workload (at $.notifier.poll_interval)
3836
// warning: interval is very fast: may result in increased workload (at $.notifier.delivery_interval)
37+
// warning: listen network not provided, default will be used (at $.api.v1.network)
38+
// warning: listen address not provided, default will be used (at $.api.v1.address)
39+
// warning: listen network not provided, default will be used (at $.introspection.network)
40+
// warning: listen address not provided, default will be used (at $.introspection.address)
3941
}

0 commit comments

Comments
 (0)