Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions internal/controller/genericprovider_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ func (r *GenericProviderReconciler) Reconcile(ctx context.Context, req reconcile
}

func patchProvider(ctx context.Context, provider operatorv1.GenericProvider, patchHelper *patch.Helper, options ...patch.Option) error {
// Fix existing conditions to ensure they have required Reason field
normalizeExistingConditions(provider)

conds := []string{
operatorv1.PreflightCheckCondition,
operatorv1.ProviderInstalledCondition,
Expand All @@ -203,6 +206,26 @@ func patchProvider(ctx context.Context, provider operatorv1.GenericProvider, pat
return patchHelper.Patch(ctx, provider, options...)
}

// normalizeExistingConditions ensures all existing conditions have required Reason field.
func normalizeExistingConditions(provider operatorv1.GenericProvider) {
conditions := provider.GetConditions()
modified := false

for i := range conditions {
condition := &conditions[i]

// Set reason to condition type if empty
if condition.Reason == "" {
condition.Reason = condition.Type
modified = true
}
}

if modified {
provider.SetConditions(conditions)
}
}

func (r *GenericProviderReconciler) reconcile(ctx context.Context) (*Result, error) {
var res Result

Expand Down