forked from feedhenry/fh-system-dump-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenshift_metadata.go
35 lines (33 loc) · 936 Bytes
/
openshift_metadata.go
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
package main
import (
"os/exec"
"path/filepath"
"strings"
)
// GetOpenShiftMetadataTasks sends tasks to fetch OpenShift metadata about
// versions, current user and its permissions.
func GetOpenShiftMetadataTasks(tasks chan<- Task, runner Runner, projects []string) {
argsList := [][]string{
{"version"},
{"whoami"},
{"policy", "can-i", "list", "projects"},
{"policy", "can-i", "list", "persistentvolumes"},
{"policy", "can-i", "list", "nodes"},
}
for _, args := range argsList {
args := args
tasks <- func() error {
cmd := exec.Command("oc", args...)
path := filepath.Join("meta", "oc_"+strings.Join(args, "_"))
return runner.Run(cmd, path)
}
}
for _, p := range projects {
p := p
tasks <- func() error {
cmd := exec.Command("oc", "-n", p, "policy", "can-i", "--list")
path := filepath.Join("meta", "projects", p, "oc_-n_"+p+"_policy_can-i_--list")
return runner.Run(cmd, path)
}
}
}