AllPodsHaveAnnotations verifies if the annotations defined in a map are included in all the pods of a cluster
( ctx context.Context, crudClient client.Client, namespace, clusterName string, annotations map[string]string, )
| 66 | // AllPodsHaveAnnotations verifies if the annotations defined in a map are included |
| 67 | // in all the pods of a cluster |
| 68 | func AllPodsHaveAnnotations( |
| 69 | ctx context.Context, |
| 70 | crudClient client.Client, |
| 71 | namespace, clusterName string, |
| 72 | annotations map[string]string, |
| 73 | ) (bool, error) { |
| 74 | cluster, err := Get(ctx, crudClient, namespace, clusterName) |
| 75 | if err != nil { |
| 76 | return false, err |
| 77 | } |
| 78 | podList, err := ListPods(ctx, crudClient, namespace, clusterName) |
| 79 | if err != nil { |
| 80 | return false, err |
| 81 | } |
| 82 | if len(podList.Items) != cluster.Spec.Instances { |
| 83 | return false, fmt.Errorf("%v found instances, %v expected", len(podList.Items), cluster.Spec.Instances) |
| 84 | } |
| 85 | for _, pod := range podList.Items { |
| 86 | if !pods.HasAnnotations(pod, annotations) { |
| 87 | return false, fmt.Errorf("%v found annotations, %v expected", pod.Annotations, annotations) |
| 88 | } |
| 89 | } |
| 90 | return true, nil |
| 91 | } |
| 92 | |
| 93 | // HasLabels verifies that the labels of a cluster contain a specified |
| 94 | // labels map |
no test coverage detected