master
go 56 lines 1.25 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package discovery
4
5 import (
6 "errors"
7 "io"
8
9 "github.com/netdata/netdata/go/plugins/pkg/multipath"
10 "github.com/netdata/netdata/go/plugins/plugin/agent/policy"
11 "github.com/netdata/netdata/go/plugins/plugin/framework/confgroup"
12 "github.com/netdata/netdata/go/plugins/plugin/framework/functions"
13 )
14
15 type (
16 PlatformPolicy struct {
17 IsInsideK8s bool
18 }
19 PluginIdentity struct {
20 Name string
21 }
22 PathsConfig struct {
23 PluginConfigDir multipath.MultiPath
24 CollectorsConfigDir multipath.MultiPath
25 CollectorsConfigWatchPath []string
26 ServiceDiscoveryConfigDir multipath.MultiPath
27 VarLibDir string
28 }
29 BuildContext struct {
30 Policy PlatformPolicy
31 RunMode policy.RunModePolicy
32 Identity PluginIdentity
33 Out io.Writer
34 Paths PathsConfig
35 Registry confgroup.Registry
36 ReadPaths []string
37 DummyNames []string
38 FnReg functions.Registry
39 }
40 )
41
42 type Config struct {
43 Registry confgroup.Registry
44 BuildContext BuildContext
45 Providers []ProviderFactory
46 }
47
48 func validateConfig(cfg Config) error {
49 if len(cfg.Registry) == 0 {
50 return errors.New("empty config registry")
51 }
52 if len(cfg.Providers) == 0 {
53 return errors.New("discoverers not set")
54 }
55 return nil
56 }