aboutsummaryrefslogtreecommitdiffstats
path: root/test/security/k8s/src/check/check.go
blob: cf412c112fa7ab8854c0dbd2a1beb4dc3dda9a4c (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package check

// Informer collects and returns information on cluster.
type Informer interface {
	// GetAPIParams returns API server parameters.
	GetAPIParams() ([]string, error)
	// GetSchedulerParams returns scheduler parameters.
	GetSchedulerParams() ([]string, error)
	// GetControllerManagerParams returns controller manager parameters.
	GetControllerManagerParams() ([]string, error)
}

// Command represents commands run on cluster.
type Command int

const (
	// APIProcess represents API server command ("kube-apiserver").
	APIProcess Command = iota
	// SchedulerProcess represents scheduler command ("kube-scheduler").
	SchedulerProcess
	// ControllerManagerProcess represents controller manager command ("kube-controller-manager").
	ControllerManagerProcess
)

func (c Command) String() string {
	names := [...]string{
		"kube-apiserver",
		"kube-scheduler",
		"kube-controller-manager",
	}

	if c < APIProcess || c > ControllerManagerProcess {
		return "exit"
	}
	return names[c]
}

// Service represents services run on Rancher-based cluster.
type Service int

const (
	// APIService represents API server service ("kubernetes/kubernetes").
	APIService Service = iota
	// SchedulerService represents scheduler service ("kubernetes/scheduler").
	SchedulerService
	// ControllerManagerService represents controller manager service ("kubernetes/controller-manager").
	ControllerManagerService
)

func (s Service) String() string {
	names := [...]string{
		"kubernetes/kubernetes",
		"kubernetes/scheduler",
		"kubernetes/controller-manager",
	}

	if s < APIService || s > ControllerManagerService {
		return ""
	}
	return names[s]
}