MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / GetReplicas

Function GetReplicas

tests/utils/clusterutils/cluster.go:191–211  ·  view source on GitHub ↗

GetReplicas gets a slice containing all the replica pods of a cluster

(
	ctx context.Context,
	crudClient client.Client,
	namespace, clusterName string,
)

Source from the content-addressed store, hash-verified

189
190// GetReplicas gets a slice containing all the replica pods of a cluster
191func 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
214func GetFirstReplica(

Calls 1

ListFunction · 0.92

Tested by

no test coverage detected