summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/agent/discovery/sd/discoverer/kubernetes/config.go
blob: 15a1e474546bfbca464275477bd440eb5140c1d1 (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
30
31
32
33
34
// SPDX-License-Identifier: GPL-3.0-or-later

package kubernetes

import (
	"errors"
	"fmt"
)

type Config struct {
	APIServer  string   `yaml:"api_server"` // TODO: not used
	Role       string   `yaml:"role"`
	Tags       string   `yaml:"tags"`
	Namespaces []string `yaml:"namespaces"`
	Selector   struct {
		Label string `yaml:"label"`
		Field string `yaml:"field"`
	} `yaml:"selector"`
	Pod struct {
		LocalMode bool `yaml:"local_mode"`
	} `yaml:"pod"`
}

func validateConfig(cfg Config) error {
	switch role(cfg.Role) {
	case rolePod, roleService:
	default:
		return fmt.Errorf("unknown role: '%s'", cfg.Role)
	}
	if cfg.Tags == "" {
		return errors.New("'tags' not set")
	}
	return nil
}