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

Function getDeploymentOrNil

internal/controller/pooler_resources.go:177–191  ·  view source on GitHub ↗

getDeploymentOrNil gets a deployment 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

175
176// getDeploymentOrNil gets a deployment with a certain name, returning nil when it doesn't exist
177func getDeploymentOrNil(
178 ctx context.Context, r client.Client, objectKey client.ObjectKey,
179) (*appsv1.Deployment, error) {
180 var deployment appsv1.Deployment
181 err := r.Get(ctx, objectKey, &deployment)
182 if err != nil {
183 if apierrs.IsNotFound(err) {
184 return nil, nil
185 }
186
187 return nil, err
188 }
189
190 return &deployment, nil
191}
192
193// getServiceOrNil gets a service with a certain name, returning nil when it doesn't exist
194func getServiceOrNil(ctx context.Context, r client.Client, objectKey client.ObjectKey) (*corev1.Service, error) {

Callers 2

getManagedResourcesMethod · 0.85

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected