GetReplicas gets a slice containing all the replica pods of a cluster
( ctx context.Context, crudClient client.Client, namespace, clusterName string, )
| 189 | |
| 190 | // GetReplicas gets a slice containing all the replica pods of a cluster |
| 191 | func GetReplicas( |
| 192 | ctx context.Context, |
| 193 | crudClient client.Client, |
| 194 | namespace, clusterName string, |
| 195 | ) (*corev1.PodList, error) { |
| 196 | podList := &corev1.PodList{} |
| 197 | err := objects.List(ctx, crudClient, podList, client.InNamespace(namespace), |
| 198 | client.MatchingLabels{ |
| 199 | utils.ClusterLabelName: clusterName, |
| 200 | utils.ClusterInstanceRoleLabelName: specs.ClusterRoleLabelReplica, |
| 201 | }, |
| 202 | ) |
| 203 | if err != nil { |
| 204 | return podList, err |
| 205 | } |
| 206 | if len(podList.Items) > 0 { |
| 207 | return podList, nil |
| 208 | } |
| 209 | err = fmt.Errorf("no replicas found") |
| 210 | return podList, err |
| 211 | } |
| 212 | |
| 213 | // GetFirstReplica gets the first replica pod from a cluster |
| 214 | func GetFirstReplica( |
no test coverage detected