Skip to content

Commit d19e7bc

Browse files
committed
Use bipolarity option in gitrepo and ocirepo
Use the bipolarity condition options in OCIRepository and GitRepository reconcilers. Signed-off-by: Sunny <[email protected]>
1 parent 0f15f04 commit d19e7bc

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

controllers/gitrepository_controller.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques
194194
summarizeHelper := summarize.NewHelper(r.EventRecorder, patchHelper)
195195
summarizeOpts := []summarize.Option{
196196
summarize.WithConditions(gitRepositoryReadyCondition),
197+
summarize.WithBiPolarityConditionTypes(sourcev1.SourceVerifiedCondition),
197198
summarize.WithReconcileResult(recResult),
198199
summarize.WithReconcileError(retErr),
199200
summarize.WithIgnoreNotFound(),
@@ -430,6 +431,15 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
430431
errors.New("libgit2 managed transport not initialized"), "Libgit2TransportNotEnabled",
431432
)
432433
}
434+
435+
// Remove previously failed source verification status conditions. The
436+
// failing verification should be recalculated. But an existing successful
437+
// verification need not be removed as it indicates verification of previous
438+
// version.
439+
if conditions.IsFalse(obj, sourcev1.SourceVerifiedCondition) {
440+
conditions.Delete(obj, sourcev1.SourceVerifiedCondition)
441+
}
442+
433443
// Configure authentication strategy to access the source
434444
var authOpts *git.AuthOptions
435445
var err error

controllers/ocirepository_controller.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ func (r *OCIRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Reques
191191
summarizeHelper := summarize.NewHelper(r.EventRecorder, patchHelper)
192192
summarizeOpts := []summarize.Option{
193193
summarize.WithConditions(ociRepositoryReadyCondition),
194+
summarize.WithBiPolarityConditionTypes(sourcev1.SourceVerifiedCondition),
194195
summarize.WithReconcileResult(recResult),
195196
summarize.WithReconcileError(retErr),
196197
summarize.WithIgnoreNotFound(),
@@ -294,6 +295,14 @@ func (r *OCIRepositoryReconciler) reconcileSource(ctx context.Context, obj *sour
294295
ctxTimeout, cancel := context.WithTimeout(ctx, obj.Spec.Timeout.Duration)
295296
defer cancel()
296297

298+
// Remove previously failed source verification status conditions. The
299+
// failing verification should be recalculated. But an existing successful
300+
// verification need not be removed as it indicates verification of previous
301+
// version.
302+
if conditions.IsFalse(obj, sourcev1.SourceVerifiedCondition) {
303+
conditions.Delete(obj, sourcev1.SourceVerifiedCondition)
304+
}
305+
297306
options := r.craneOptions(ctxTimeout, obj.Spec.Insecure)
298307

299308
// Generate the registry credential keychain either from static credentials or using cloud OIDC

0 commit comments

Comments
 (0)