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 | f649f22 | 2019-10-07 17:00:49 +0200 | [diff] [blame^] | 11 | // GetEtcdParams returns etcd parameters. |
| 12 | GetEtcdParams() ([]string, error) |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | // Command represents commands run on cluster. |
| 16 | type Command int |
| 17 | |
| 18 | const ( |
| 19 | // APIProcess represents API server command ("kube-apiserver"). |
| 20 | APIProcess Command = iota |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 21 | // SchedulerProcess represents scheduler command ("kube-scheduler"). |
| 22 | SchedulerProcess |
Pawel Wieczorek | 5a61d61 | 2019-09-27 18:26:13 +0200 | [diff] [blame] | 23 | // ControllerManagerProcess represents controller manager command ("kube-controller-manager"). |
| 24 | ControllerManagerProcess |
Pawel Wieczorek | f649f22 | 2019-10-07 17:00:49 +0200 | [diff] [blame^] | 25 | // EtcdProcess represents controller manager service ("etcd"). |
| 26 | EtcdProcess |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 27 | ) |
| 28 | |
| 29 | func (c Command) String() string { |
| 30 | names := [...]string{ |
| 31 | "kube-apiserver", |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 32 | "kube-scheduler", |
Pawel Wieczorek | 5a61d61 | 2019-09-27 18:26:13 +0200 | [diff] [blame] | 33 | "kube-controller-manager", |
Pawel Wieczorek | f649f22 | 2019-10-07 17:00:49 +0200 | [diff] [blame^] | 34 | "etcd", |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 35 | } |
| 36 | |
Pawel Wieczorek | f649f22 | 2019-10-07 17:00:49 +0200 | [diff] [blame^] | 37 | if c < APIProcess || c > EtcdProcess { |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 38 | return "exit" |
| 39 | } |
| 40 | return names[c] |
| 41 | } |
| 42 | |
| 43 | // Service represents services run on Rancher-based cluster. |
| 44 | type Service int |
| 45 | |
| 46 | const ( |
| 47 | // APIService represents API server service ("kubernetes/kubernetes"). |
| 48 | APIService Service = iota |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 49 | // SchedulerService represents scheduler service ("kubernetes/scheduler"). |
| 50 | SchedulerService |
Pawel Wieczorek | 5a61d61 | 2019-09-27 18:26:13 +0200 | [diff] [blame] | 51 | // ControllerManagerService represents controller manager service ("kubernetes/controller-manager"). |
| 52 | ControllerManagerService |
Pawel Wieczorek | f649f22 | 2019-10-07 17:00:49 +0200 | [diff] [blame^] | 53 | // EtcdService represents etcd service ("kubernetes/etcd"). |
| 54 | EtcdService |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 55 | ) |
| 56 | |
| 57 | func (s Service) String() string { |
| 58 | names := [...]string{ |
| 59 | "kubernetes/kubernetes", |
Pawel Wieczorek | 96f4e2f | 2019-09-27 16:10:33 +0200 | [diff] [blame] | 60 | "kubernetes/scheduler", |
Pawel Wieczorek | 5a61d61 | 2019-09-27 18:26:13 +0200 | [diff] [blame] | 61 | "kubernetes/controller-manager", |
Pawel Wieczorek | f649f22 | 2019-10-07 17:00:49 +0200 | [diff] [blame^] | 62 | "kubernetes/etcd", |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 63 | } |
| 64 | |
Pawel Wieczorek | f649f22 | 2019-10-07 17:00:49 +0200 | [diff] [blame^] | 65 | if s < APIService || s > EtcdService { |
Pawel Wieczorek | 76dd9bf | 2019-09-26 16:43:01 +0200 | [diff] [blame] | 66 | return "" |
| 67 | } |
| 68 | return names[s] |
| 69 | } |