Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 1 | package check |
| 2 | |
| 3 | // Informer collects and returns information on cluster. |
| 4 | type Informer interface { |
| 5 | // GetAPIParams returns API server parameters. |
| 6 | GetAPIParams() ([]string, error) |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 7 | // GetSchedulerParams returns scheduler parameters. |
| 8 | GetSchedulerParams() ([]string, error) |
Pawel Wieczorek | 5a61d61 | 2019-09-27 18:26:13 +0200 | [diff] [blame] | 9 | // GetControllerManagerParams returns controller manager parameters. |
| 10 | GetControllerManagerParams() ([]string, error) |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 11 | } |
| 12 | |
| 13 | // Command represents commands run on cluster. |
| 14 | type Command int |
| 15 | |
| 16 | const ( |
| 17 | // APIProcess represents API server command ("kube-apiserver"). |
| 18 | APIProcess Command = iota |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 19 | // SchedulerProcess represents scheduler command ("kube-scheduler"). |
| 20 | SchedulerProcess |
Pawel Wieczorek | 5a61d61 | 2019-09-27 18:26:13 +0200 | [diff] [blame] | 21 | // ControllerManagerProcess represents controller manager command ("kube-controller-manager"). |
| 22 | ControllerManagerProcess |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 23 | ) |
| 24 | |
| 25 | func (c Command) String() string { |
| 26 | names := [...]string{ |
| 27 | "kube-apiserver", |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 28 | "kube-scheduler", |
Pawel Wieczorek | 5a61d61 | 2019-09-27 18:26:13 +0200 | [diff] [blame] | 29 | "kube-controller-manager", |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 30 | } |
| 31 | |
Pawel Wieczorek | 5a61d61 | 2019-09-27 18:26:13 +0200 | [diff] [blame] | 32 | if c < APIProcess || c > ControllerManagerProcess { |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 33 | return "exit" |
| 34 | } |
| 35 | return names[c] |
| 36 | } |
| 37 | |
| 38 | // Service represents services run on Rancher-based cluster. |
| 39 | type Service int |
| 40 | |
| 41 | const ( |
| 42 | // APIService represents API server service ("kubernetes/kubernetes"). |
| 43 | APIService Service = iota |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 44 | // SchedulerService represents scheduler service ("kubernetes/scheduler"). |
| 45 | SchedulerService |
Pawel Wieczorek | 5a61d61 | 2019-09-27 18:26:13 +0200 | [diff] [blame] | 46 | // ControllerManagerService represents controller manager service ("kubernetes/controller-manager"). |
| 47 | ControllerManagerService |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 48 | ) |
| 49 | |
| 50 | func (s Service) String() string { |
| 51 | names := [...]string{ |
| 52 | "kubernetes/kubernetes", |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 53 | "kubernetes/scheduler", |
Pawel Wieczorek | 5a61d61 | 2019-09-27 18:26:13 +0200 | [diff] [blame] | 54 | "kubernetes/controller-manager", |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 55 | } |
| 56 | |
Pawel Wieczorek | 5a61d61 | 2019-09-27 18:26:13 +0200 | [diff] [blame] | 57 | if s < APIService || s > ControllerManagerService { |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 58 | return "" |
| 59 | } |
| 60 | return names[s] |
| 61 | } |