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

Function getServiceOrNil

internal/controller/pooler_resources.go:194–206  ·  view source on GitHub ↗

getServiceOrNil gets a service 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

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) {
195 var service corev1.Service
196 err := r.Get(ctx, objectKey, &service)
197 if err != nil {
198 if apierrs.IsNotFound(err) {
199 return nil, nil
200 }
201
202 return nil, err
203 }
204
205 return &service, nil
206}
207
208// getServiceAccountOrNil gets a service account with a certain name, returning nil when it doesn't exist
209func getServiceAccountOrNil(

Callers 2

getManagedResourcesMethod · 0.85

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected