func()

in internal/handler/appdeployment.go [108:129]


func (a *AppDeploymentHandler) EnsureDependenciesReady(ctx context.Context) (reconciler.OperationResult, error) {
	if !a.phaseIs(v1alpha1.AppDeploymentPhasePending) {
		return reconciler.ContinueProcessing()
	}
	a.logger.V(1).Info("Operation EnsureDependenciesReady")
	// list all dependencies and check if they are ready
	for _, dep := range a.appDeployment.Spec.Dependencies {
		// check if dependency is ready
		appdeployment := &v1alpha1.AppDeployment{}
		realAppName := ctrlutils.OperationScopedAppDeployment(dep, a.appDeployment.Spec.OpId)
		if err := a.client.Get(ctx, client.ObjectKey{Namespace: a.appDeployment.Namespace, Name: realAppName}, appdeployment); err != nil {
			a.logger.V(1).Error(err, "dependency not found", "dependency", realAppName)
			return reconciler.RequeueWithError(fmt.Errorf("dependency not found: %s ", realAppName))
		}
		if appdeployment.Status.Phase != v1alpha1.AppDeploymentPhaseReady {
			return reconciler.RequeueWithError(fmt.Errorf("dependency is not ready: %s", realAppName))
		}
	}
	// all dependencies are ready
	a.appDeployment.Status.Phase = v1alpha1.AppDeploymentPhaseDeploying
	return reconciler.RequeueOnErrorOrContinue(a.client.Status().Update(ctx, a.appDeployment))
}