diff options
author | Pawel Wieczorek <p.wieczorek2@samsung.com> | 2019-09-26 16:43:01 +0200 |
---|---|---|
committer | Pawel Wieczorek <p.wieczorek2@samsung.com> | 2019-09-27 17:38:49 +0200 |
commit | 76dd9bfcc14f2a77dd9a8155e66434a304cd0c38 (patch) | |
tree | 19f1f23dee938ccf423c7bbd399a586d0cfe9079 /test/security/k8s/src/check/check.go | |
parent | 664ce36e4606ba855bb997059f43d89bb51385e5 (diff) |
k8s: Extract common interface to simplify development
Common command and service name extraction is intended to limit
execution to small set of allowed processes.
This patch also drops unnecessary use of "Kubernetes" name because this
whole subproject concerns its clusters.
Issue-ID: SECCOM-235
Change-Id: I8babfeb4f24cf3baa4d236ca622c21170ab6205e
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
Diffstat (limited to 'test/security/k8s/src/check/check.go')
-rw-r--r-- | test/security/k8s/src/check/check.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/security/k8s/src/check/check.go b/test/security/k8s/src/check/check.go new file mode 100644 index 000000000..c185887d7 --- /dev/null +++ b/test/security/k8s/src/check/check.go @@ -0,0 +1,45 @@ +package check + +// Informer collects and returns information on cluster. +type Informer interface { + // GetAPIParams returns API server parameters. + GetAPIParams() ([]string, error) +} + +// Command represents commands run on cluster. +type Command int + +const ( + // APIProcess represents API server command ("kube-apiserver"). + APIProcess Command = iota +) + +func (c Command) String() string { + names := [...]string{ + "kube-apiserver", + } + + if c < APIProcess || c > APIProcess { + 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 +) + +func (s Service) String() string { + names := [...]string{ + "kubernetes/kubernetes", + } + + if s < APIService || s > APIService { + return "" + } + return names[s] +} |