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

Function IsReady

tests/utils/operator/operator.go:169–206  ·  view source on GitHub ↗

IsReady ensures that the operator will be ready.

(
	ctx context.Context,
	crudClient client.Client,
	checkWebhook bool,
)

Source from the content-addressed store, hash-verified

167
168// IsReady ensures that the operator will be ready.
169func IsReady(
170 ctx context.Context,
171 crudClient client.Client,
172 checkWebhook bool,
173) (bool, error) {
174 if ready, err := isDeploymentReady(ctx, crudClient); err != nil || !ready {
175 return ready, err
176 }
177
178 // If the operator is not managing webhooks, we don't need to check. Exit early
179 if !checkWebhook {
180 return true, nil
181 }
182
183 deploy, err := GetDeployment(ctx, crudClient)
184 if err != nil {
185 return false, err
186 }
187 namespace := deploy.GetNamespace()
188
189 // Detect if we are running under OLM
190 var webhookManagedByOLM bool
191 for _, envVar := range deploy.Spec.Template.Spec.Containers[0].Env {
192 if envVar.Name == "WEBHOOK_CERT_DIR" {
193 webhookManagedByOLM = true
194 }
195 }
196
197 // If the operator is managing certificates for webhooks, check that the setup is completed
198 if !webhookManagedByOLM {
199 err = checkWebhookSetup(ctx, crudClient, namespace)
200 if err != nil {
201 return false, err
202 }
203 }
204
205 return isWebhookWorking(ctx, crudClient)
206}
207
208// WaitForReady waits for the operator deployment to be ready.
209// If checkWebhook is true, it will also check that the webhook is replying

Callers 4

webhook_test.goFile · 0.92
WaitForReadyFunction · 0.70

Calls 5

isDeploymentReadyFunction · 0.85
GetDeploymentFunction · 0.85
checkWebhookSetupFunction · 0.85
isWebhookWorkingFunction · 0.85
GetNamespaceMethod · 0.45

Tested by

no test coverage detected