@@ -32,7 +32,7 @@ import (
3232 "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
3333 "sigs.k8s.io/controller-runtime/pkg/predicate"
3434
35- placementv1alpha1 "github.com/arvindthiru/kubefleet-cookbook/approval-controller-metric-collector/approval-request-controller/apis/metric/v1alpha1"
35+ localv1alpha1 "github.com/arvindthiru/kubefleet-cookbook/approval-controller-metric-collector/approval-request-controller/apis/metric/v1alpha1"
3636)
3737
3838const (
@@ -68,7 +68,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
6868 }()
6969
7070 // Fetch the MetricCollector instance (cluster-scoped)
71- mc := & placementv1alpha1 .MetricCollector {}
71+ mc := & localv1alpha1 .MetricCollector {}
7272 if err := r .MemberClient .Get (ctx , client.ObjectKey {Name : req .Name }, mc ); err != nil {
7373 if errors .IsNotFound (err ) {
7474 klog .V (2 ).InfoS ("MetricCollector not found, ignoring" , "metricCollector" , req .Name )
@@ -123,14 +123,14 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
123123 if collectErr != nil {
124124 klog .ErrorS (collectErr , "Failed to collect metrics" , "metricCollector" , req .Name )
125125 meta .SetStatusCondition (& mc .Status .Conditions , metav1.Condition {
126- Type : placementv1alpha1 .MetricCollectorConditionTypeReady ,
126+ Type : localv1alpha1 .MetricCollectorConditionTypeReady ,
127127 Status : metav1 .ConditionTrue ,
128128 ObservedGeneration : mc .Generation ,
129129 Reason : "CollectorConfigured" ,
130130 Message : "Collector is configured" ,
131131 })
132132 meta .SetStatusCondition (& mc .Status .Conditions , metav1.Condition {
133- Type : placementv1alpha1 .MetricCollectorConditionTypeCollecting ,
133+ Type : localv1alpha1 .MetricCollectorConditionTypeCollecting ,
134134 Status : metav1 .ConditionFalse ,
135135 ObservedGeneration : mc .Generation ,
136136 Reason : "CollectionFailed" ,
@@ -139,14 +139,14 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
139139 } else {
140140 klog .V (2 ).InfoS ("Successfully collected metrics" , "metricCollector" , req .Name , "workloads" , len (collectedMetrics ))
141141 meta .SetStatusCondition (& mc .Status .Conditions , metav1.Condition {
142- Type : placementv1alpha1 .MetricCollectorConditionTypeReady ,
142+ Type : localv1alpha1 .MetricCollectorConditionTypeReady ,
143143 Status : metav1 .ConditionTrue ,
144144 ObservedGeneration : mc .Generation ,
145145 Reason : "CollectorConfigured" ,
146146 Message : "Collector is configured and collecting metrics" ,
147147 })
148148 meta .SetStatusCondition (& mc .Status .Conditions , metav1.Condition {
149- Type : placementv1alpha1 .MetricCollectorConditionTypeCollecting ,
149+ Type : localv1alpha1 .MetricCollectorConditionTypeCollecting ,
150150 Status : metav1 .ConditionTrue ,
151151 ObservedGeneration : mc .Generation ,
152152 Reason : "MetricsCollected" ,
@@ -163,15 +163,15 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
163163 if err := r .syncReportToHub (ctx , mc ); err != nil {
164164 klog .ErrorS (err , "Failed to sync MetricCollectorReport to hub" , "metricCollector" , req .Name )
165165 meta .SetStatusCondition (& mc .Status .Conditions , metav1.Condition {
166- Type : placementv1alpha1 .MetricCollectorConditionTypeReported ,
166+ Type : localv1alpha1 .MetricCollectorConditionTypeReported ,
167167 Status : metav1 .ConditionFalse ,
168168 ObservedGeneration : mc .Generation ,
169169 Reason : "ReportSyncFailed" ,
170170 Message : fmt .Sprintf ("Failed to sync report to hub: %v" , err ),
171171 })
172172 } else {
173173 meta .SetStatusCondition (& mc .Status .Conditions , metav1.Condition {
174- Type : placementv1alpha1 .MetricCollectorConditionTypeReported ,
174+ Type : localv1alpha1 .MetricCollectorConditionTypeReported ,
175175 Status : metav1 .ConditionTrue ,
176176 ObservedGeneration : mc .Generation ,
177177 Reason : "ReportSyncSucceeded" ,
@@ -190,15 +190,15 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
190190}
191191
192192// syncReportToHub syncs the MetricCollectorReport to the hub cluster
193- func (r * Reconciler ) syncReportToHub (ctx context.Context , mc * placementv1alpha1 .MetricCollector ) error {
193+ func (r * Reconciler ) syncReportToHub (ctx context.Context , mc * localv1alpha1 .MetricCollector ) error {
194194 // Use the reportNamespace from the MetricCollector spec
195195 reportNamespace := mc .Spec .ReportNamespace
196196 if reportNamespace == "" {
197197 return fmt .Errorf ("reportNamespace is not set in MetricCollector spec" )
198198 }
199199
200200 // Create or update MetricCollectorReport on hub
201- report := & placementv1alpha1 .MetricCollectorReport {
201+ report := & localv1alpha1 .MetricCollectorReport {
202202 ObjectMeta : metav1.ObjectMeta {
203203 Name : mc .Name ,
204204 Namespace : reportNamespace ,
@@ -209,7 +209,7 @@ func (r *Reconciler) syncReportToHub(ctx context.Context, mc *placementv1alpha1.
209209 }
210210
211211 // Check if report already exists
212- existingReport := & placementv1alpha1 .MetricCollectorReport {}
212+ existingReport := & localv1alpha1 .MetricCollectorReport {}
213213 err := r .HubClient .Get (ctx , client.ObjectKey {Name : mc .Name , Namespace : reportNamespace }, existingReport )
214214
215215 now := metav1 .Now ()
@@ -251,7 +251,7 @@ func (r *Reconciler) syncReportToHub(ctx context.Context, mc *placementv1alpha1.
251251}
252252
253253// deleteReportFromHub deletes the MetricCollectorReport from the hub cluster
254- func (r * Reconciler ) deleteReportFromHub (ctx context.Context , mc * placementv1alpha1 .MetricCollector ) error {
254+ func (r * Reconciler ) deleteReportFromHub (ctx context.Context , mc * localv1alpha1 .MetricCollector ) error {
255255 // Use the reportNamespace from the MetricCollector spec
256256 reportNamespace := mc .Spec .ReportNamespace
257257 if reportNamespace == "" {
@@ -260,7 +260,7 @@ func (r *Reconciler) deleteReportFromHub(ctx context.Context, mc *placementv1alp
260260 }
261261
262262 // Try to delete MetricCollectorReport on hub
263- report := & placementv1alpha1 .MetricCollectorReport {}
263+ report := & localv1alpha1 .MetricCollectorReport {}
264264 err := r .HubClient .Get (ctx , client.ObjectKey {Name : mc .Name , Namespace : reportNamespace }, report )
265265 if err != nil {
266266 if errors .IsNotFound (err ) {
@@ -283,6 +283,6 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
283283 r .recorder = mgr .GetEventRecorderFor ("metriccollector-controller" )
284284 return ctrl .NewControllerManagedBy (mgr ).
285285 Named ("metriccollector-controller" ).
286- For (& placementv1alpha1 .MetricCollector {}, builder .WithPredicates (predicate.GenerationChangedPredicate {})).
286+ For (& localv1alpha1 .MetricCollector {}, builder .WithPredicates (predicate.GenerationChangedPredicate {})).
287287 Complete (r )
288288}
0 commit comments