Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit 07b6600

Browse files
committed
fix: removing reconciliation status
1 parent 9c1afc8 commit 07b6600

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

controllers/delivery/sync_controller.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"fmt"
1111
"time"
1212

13-
eventv1 "github.com/fluxcd/pkg/apis/event/v1beta1"
1413
"github.com/fluxcd/pkg/apis/meta"
1514
"github.com/fluxcd/pkg/runtime/conditions"
1615
"github.com/fluxcd/pkg/runtime/patch"
@@ -31,7 +30,6 @@ import (
3130
"github.com/open-component-model/git-controller/apis/delivery/v1alpha1"
3231
mpasv1alpha1 "github.com/open-component-model/git-controller/apis/mpas/v1alpha1"
3332
"github.com/open-component-model/git-controller/pkg"
34-
"github.com/open-component-model/git-controller/pkg/event"
3533
"github.com/open-component-model/git-controller/pkg/providers"
3634
)
3735

@@ -89,8 +87,8 @@ func (r *SyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctr
8987

9088
// it's important that this happens here so any residual status condition can be overwritten / set.
9189
if obj.Status.Digest != "" {
92-
event.New(r.EventRecorder, obj, eventv1.EventSeverityInfo, fmt.Sprintf("sync object already synced with digest %s", obj.Status.Digest), nil)
93-
conditions.MarkTrue(obj, meta.ReadyCondition, meta.SucceededReason, "Reconciliation success")
90+
// we should be already Ready, deleting reconciling condition only.
91+
conditions.Delete(obj, meta.ReconcilingCondition)
9492

9593
return ctrl.Result{}, nil
9694
}
@@ -199,8 +197,7 @@ func (r *SyncReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctr
199197
obj.Status.PullRequestID = id
200198
}
201199

202-
conditions.MarkTrue(obj, meta.ReadyCondition, meta.SucceededReason, "Reconciliation success")
203-
event.New(r.EventRecorder, obj, eventv1.EventSeverityInfo, "Reconciliation success", nil)
200+
status.MarkReady(r.EventRecorder, obj, "Reconciliation success")
204201

205202
return ctrl.Result{}, nil
206203
}

controllers/mpas/repository_controller.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import (
99
"errors"
1010
"fmt"
1111

12-
eventv1 "github.com/fluxcd/pkg/apis/event/v1beta1"
1312
"github.com/fluxcd/pkg/apis/meta"
14-
"github.com/fluxcd/pkg/runtime/conditions"
1513
"github.com/fluxcd/pkg/runtime/patch"
1614
rreconcile "github.com/fluxcd/pkg/runtime/reconcile"
1715
"github.com/open-component-model/ocm-controller/pkg/status"
@@ -24,7 +22,6 @@ import (
2422
"sigs.k8s.io/controller-runtime/pkg/predicate"
2523

2624
mpasv1alpha1 "github.com/open-component-model/git-controller/apis/mpas/v1alpha1"
27-
"github.com/open-component-model/git-controller/pkg/event"
2825
"github.com/open-component-model/git-controller/pkg/providers"
2926
)
3027

@@ -107,7 +104,7 @@ func (r *RepositoryReconciler) reconcile(ctx context.Context, obj *mpasv1alpha1.
107104

108105
if err := r.Provider.CreateBranchProtection(ctx, *obj); err != nil {
109106
if errors.Is(err, providers.NotSupportedError) {
110-
r.markAsDone(obj)
107+
status.MarkReady(r.EventRecorder, obj, "Successful reconciliation")
111108

112109
// ignore and return without branch protection rules.
113110
return ctrl.Result{}, nil
@@ -119,12 +116,7 @@ func (r *RepositoryReconciler) reconcile(ctx context.Context, obj *mpasv1alpha1.
119116
return ctrl.Result{}, err
120117
}
121118

122-
r.markAsDone(obj)
119+
status.MarkReady(r.EventRecorder, obj, "Successful reconciliation")
123120

124121
return ctrl.Result{}, nil
125122
}
126-
127-
func (r *RepositoryReconciler) markAsDone(obj *mpasv1alpha1.Repository) {
128-
conditions.MarkTrue(obj, meta.ReadyCondition, meta.SucceededReason, "Reconciliation success")
129-
event.New(r.EventRecorder, obj, eventv1.EventSeverityInfo, "Reconciliation success", nil)
130-
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ require (
3636
github.com/go-logr/logr v1.2.4
3737
github.com/google/go-github/v52 v52.0.0
3838
github.com/open-component-model/ocm v0.4.0
39-
github.com/open-component-model/ocm-controller v0.16.0
39+
github.com/open-component-model/ocm-controller v0.16.1-0.20231115142704-81cfce8cc592
4040
github.com/stretchr/testify v1.8.4
4141
golang.org/x/oauth2 v0.11.0
4242
k8s.io/api v0.28.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,8 +1226,8 @@ github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
12261226
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
12271227
github.com/open-component-model/ocm v0.4.0 h1:S+rPJGoDnSvxhBn3QS2HXURxugTjCM4XWEJLZSaH6Ek=
12281228
github.com/open-component-model/ocm v0.4.0/go.mod h1:7RAqaUMmA4BlwW5ZEUBm8amWIb1TL9FhNigNXQ6wiu0=
1229-
github.com/open-component-model/ocm-controller v0.16.0 h1:yhZI95pg/DVs59RwOl41xcePaEVQMZDx0P5CKhhebqc=
1230-
github.com/open-component-model/ocm-controller v0.16.0/go.mod h1:lYax3VEjWAZ7qEr90opJQl+qm/gO3wIeoz1WSEdje2c=
1229+
github.com/open-component-model/ocm-controller v0.16.1-0.20231115142704-81cfce8cc592 h1:G9X+Fv/kEAxCZUUJJy5uPJfpnMHmAsLwq5RKfEjsEog=
1230+
github.com/open-component-model/ocm-controller v0.16.1-0.20231115142704-81cfce8cc592/go.mod h1:lYax3VEjWAZ7qEr90opJQl+qm/gO3wIeoz1WSEdje2c=
12311231
github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
12321232
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
12331233
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=

0 commit comments

Comments
 (0)