-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpod.go
More file actions
38 lines (32 loc) · 820 Bytes
/
pod.go
File metadata and controls
38 lines (32 loc) · 820 Bytes
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
package cmd
import (
"github.com/method-security/methodk8s/internal/pod"
"github.com/spf13/cobra"
)
func (a *MethodK8s) InitPodCommand() {
podCmd := &cobra.Command{
Use: "pod",
Short: "Audit and command Pods",
Long: `Audit and command Pods`,
}
enumerateCmd := &cobra.Command{
Use: "enumerate",
Short: "Enumerate Pods",
Long: `Enumerate Pods`,
Run: func(cmd *cobra.Command, args []string) {
// Init Cmd Failed
if a.OutputSignal.ErrorMessage != nil {
return
}
report, err := pod.EnumeratePods(cmd.Context(), a.K8sConfig, a.AuthType)
if err != nil {
errorMessage := err.Error()
a.OutputSignal.ErrorMessage = &errorMessage
a.OutputSignal.Status = 1
}
a.OutputSignal.Content = report
},
}
podCmd.AddCommand(enumerateCmd)
a.RootCmd.AddCommand(podCmd)
}