-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathingress.go
More file actions
46 lines (40 loc) · 1.19 KB
/
ingress.go
File metadata and controls
46 lines (40 loc) · 1.19 KB
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
package cmd
import (
"github.com/method-security/methodk8s/internal/ingress"
"github.com/spf13/cobra"
)
func (a *MethodK8s) InitIngressCommand() {
ingressCmd := &cobra.Command{
Use: "ingress",
Short: "Audit and command Ingresses",
Long: `Audit and command Ingresses`,
}
enumerateCmd := &cobra.Command{
Use: "enumerate",
Short: "Enumerate Ingresses",
Long: `Enumerate Ingresses`,
Run: func(cmd *cobra.Command, args []string) {
// Init Cmd Failed
if a.OutputSignal.ErrorMessage != nil {
return
}
types, err := cmd.Flags().GetStringSlice("type")
if err != nil {
errorMessage := err.Error()
a.OutputSignal.ErrorMessage = &errorMessage
a.OutputSignal.Status = 1
return
}
report, err := ingress.EnumerateIngresses(cmd.Context(), a.K8sConfig, a.AuthType, types)
if err != nil {
errorMessage := err.Error()
a.OutputSignal.ErrorMessage = &errorMessage
a.OutputSignal.Status = 1
}
a.OutputSignal.Content = report
},
}
enumerateCmd.Flags().StringSlice("type", []string{}, "List the types to emumerate (ie.--type ingress --type gateway --type loadbalancer)")
ingressCmd.AddCommand(enumerateCmd)
a.RootCmd.AddCommand(ingressCmd)
}