summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/agent/discovery/config.go
blob: 6cbd2db1ebdb0f9cc183a6df7eeb120437dadd52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// SPDX-License-Identifier: GPL-3.0-or-later

package discovery

import (
	"errors"

	"github.com/netdata/netdata/go/go.d.plugin/agent/confgroup"
	"github.com/netdata/netdata/go/go.d.plugin/agent/discovery/dummy"
	"github.com/netdata/netdata/go/go.d.plugin/agent/discovery/file"
	"github.com/netdata/netdata/go/go.d.plugin/agent/discovery/sd"
)

type Config struct {
	Registry confgroup.Registry
	File     file.Config
	Dummy    dummy.Config
	SD       sd.Config
}

func validateConfig(cfg Config) error {
	if len(cfg.Registry) == 0 {
		return errors.New("empty config registry")
	}
	if len(cfg.File.Read)+len(cfg.File.Watch) == 0 && len(cfg.Dummy.Names) == 0 {
		return errors.New("discoverers not set")
	}
	return nil
}