func()

in internal/controllers/symphony/controller.go [238:279]


func (c *symphonyController) buildStatus(symph *apiv1.Symphony, comps *apiv1.CompositionList) apiv1.SymphonyStatus {
	newStatus := apiv1.SymphonyStatus{
		ObservedGeneration: symph.Generation,
	}
	synthMap := map[string]struct{}{}
	for _, comp := range comps.Items {
		synthMap[comp.Spec.Synthesizer.Name] = struct{}{}

		syn := comp.Status.CurrentSynthesis
		if syn == nil {
			continue
		}

		if newStatus.Ready.Before(syn.Ready) || newStatus.Ready == nil {
			newStatus.Ready = syn.Ready
		}
		if newStatus.Reconciled.Before(syn.Reconciled) || newStatus.Reconciled == nil {
			newStatus.Reconciled = syn.Reconciled
		}
		if newStatus.Synthesized.Before(syn.Synthesized) || newStatus.Synthesized == nil {
			newStatus.Synthesized = syn.Synthesized
		}
	}

	// Status should be nil for any states that haven't been reached by all compositions
	for _, comp := range comps.Items {
		syn := comp.Status.CurrentSynthesis
		synInvalid := syn == nil || syn.ObservedCompositionGeneration != comp.Generation || comp.DeletionTimestamp != nil

		if synInvalid || syn.Ready == nil {
			newStatus.Ready = nil
		}
		if synInvalid || syn.Reconciled == nil {
			newStatus.Reconciled = nil
		}
		if synInvalid || syn.Synthesized == nil {
			newStatus.Synthesized = nil
		}
	}

	return newStatus
}