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

Function getClusterOrNil

internal/controller/pooler_resources.go:277–289  ·  view source on GitHub ↗

getClusterOrNil gets a cluster with a certain name, returning nil when it doesn't exist

(ctx context.Context, r client.Client, objectKey client.ObjectKey)

Source from the content-addressed store, hash-verified

275
276// getClusterOrNil gets a cluster with a certain name, returning nil when it doesn't exist
277func getClusterOrNil(ctx context.Context, r client.Client, objectKey client.ObjectKey) (*apiv1.Cluster, error) {
278 var cluster apiv1.Cluster
279 err := r.Get(ctx, objectKey, &cluster)
280 if err != nil {
281 if apierrs.IsNotFound(err) {
282 return nil, nil
283 }
284
285 return nil, err
286 }
287
288 return &cluster, nil
289}

Callers 2

ReconcileMethod · 0.85

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected