aboutsummaryrefslogtreecommitdiffstats
path: root/test/security/k8s/src/check/cmd/check/check.go
blob: 80a17f0c5b70297e725fefb9f3b106c68cc4a3b8 (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
package main

import (
	"flag"
	"log"

	"check/rancher"
	"check/raw"
	"check/validators/master"
)

var (
	ranchercli = flag.Bool("ranchercli", false, "use rancher utility for accessing cluster nodes")
	rke        = flag.Bool("rke", false, "use RKE cluster definition and ssh for accessing cluster nodes (default)")
)

func main() {
	flag.Parse()
	if *ranchercli && *rke {
		log.Fatal("Not supported.")
	}

	// Use default cluster access method if none was declared explicitly.
	if !(*ranchercli || *rke) {
		*rke = true
	}

	var (
		k8sParams []string
		err       error
	)

	switch {
	case *ranchercli:
		k8sParams, err = rancher.GetK8sParams()
	case *rke:
		k8sParams, err = raw.GetK8sParams()
	default:
		log.Fatal("Missing cluster access method.")
	}

	if err != nil {
		log.Fatal(err)
	}

	master.Check(k8sParams)
}