Return errors instead of panic

This commit is contained in:
Sam Stoelinga
2022-07-21 14:47:26 -07:00
parent 75575b9f98
commit 872b97fc45
3 changed files with 33 additions and 25 deletions

View File

@ -88,7 +88,10 @@ func initMutating() {
Run: func(cmd *cobra.Command, args []string) {
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Name", "Namespace", "Mutated", "PSP"})
pods := GetPods()
pods, err := GetPods()
if err != nil {
log.Fatalln("Error getting pods", err.Error())
}
fmt.Printf("There are %d pods in the cluster\n", len(pods.Items))
for _, pod := range pods.Items {
if pspName, ok := pod.ObjectMeta.Annotations["kubernetes.io/psp"]; ok {