master
go 31 lines 856 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package k8ssd
4
5 import (
6 "fmt"
7 )
8
9 type Config struct {
10 Source string `yaml:"-" json:"-"`
11
12 APIServer string `yaml:"api_server,omitempty" json:"-"` // TODO: not used
13 Role string `yaml:"role,omitempty" json:"role,omitempty"`
14 Namespaces []string `yaml:"namespaces,omitempty" json:"namespaces,omitempty"`
15 Selector struct {
16 Label string `yaml:"label,omitempty" json:"label,omitempty"`
17 Field string `yaml:"field,omitempty" json:"field,omitempty"`
18 } `yaml:"selector,omitempty" json:"selector"`
19 Pod struct {
20 LocalMode bool `yaml:"local_mode,omitempty" json:"local_mode,omitempty"`
21 } `yaml:"pod,omitempty" json:"pod"`
22 }
23
24 func validateConfig(cfg Config) error {
25 switch role(cfg.Role) {
26 case rolePod, roleService:
27 default:
28 return fmt.Errorf("unknown role: '%s'", cfg.Role)
29 }
30 return nil
31 }