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 | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 9 | } |
| 10 | |
| 11 | // Command represents commands run on cluster. |
| 12 | type Command int |
| 13 | |
| 14 | const ( |
| 15 | // APIProcess represents API server command ("kube-apiserver"). |
| 16 | APIProcess Command = iota |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 17 | // SchedulerProcess represents scheduler command ("kube-scheduler"). |
| 18 | SchedulerProcess |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 19 | ) |
| 20 | |
| 21 | func (c Command) String() string { |
| 22 | names := [...]string{ |
| 23 | "kube-apiserver", |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 24 | "kube-scheduler", |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 25 | } |
| 26 | |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 27 | if c < APIProcess || c > SchedulerProcess { |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 28 | return "exit" |
| 29 | } |
| 30 | return names[c] |
| 31 | } |
| 32 | |
| 33 | // Service represents services run on Rancher-based cluster. |
| 34 | type Service int |
| 35 | |
| 36 | const ( |
| 37 | // APIService represents API server service ("kubernetes/kubernetes"). |
| 38 | APIService Service = iota |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 39 | // SchedulerService represents scheduler service ("kubernetes/scheduler"). |
| 40 | SchedulerService |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 41 | ) |
| 42 | |
| 43 | func (s Service) String() string { |
| 44 | names := [...]string{ |
| 45 | "kubernetes/kubernetes", |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 46 | "kubernetes/scheduler", |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 47 | } |
| 48 | |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 49 | if s < APIService || s > SchedulerService { |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 50 | return "" |
| 51 | } |
| 52 | return names[s] |
| 53 | } |