@@ -14,8 +14,10 @@ import (
1414 irimachine "github.com/ironcore-dev/ironcore/iri/apis/machine"
1515 iri "github.com/ironcore-dev/ironcore/iri/apis/machine/v1alpha1"
1616 irimeta "github.com/ironcore-dev/ironcore/iri/apis/meta/v1alpha1"
17+ poolletutils "github.com/ironcore-dev/ironcore/poollet/common/utils"
1718 "github.com/ironcore-dev/ironcore/poollet/machinepoollet/api/v1alpha1"
1819 utilclient "github.com/ironcore-dev/ironcore/utils/client"
20+ utilsmaps "github.com/ironcore-dev/ironcore/utils/maps"
1921 "github.com/ironcore-dev/ironcore/utils/predicates"
2022 "google.golang.org/grpc/codes"
2123 "google.golang.org/grpc/status"
@@ -279,21 +281,18 @@ func (r *ReservationReconciler) reconcile(ctx context.Context, log logr.Logger,
279281}
280282
281283func (r * ReservationReconciler ) iriReservationLabels (reservation * computev1alpha1.Reservation ) (map [string ]string , error ) {
282- annotations := map [string ]string {
284+ labels := map [string ]string {
283285 v1alpha1 .ReservationUIDLabel : string (reservation .UID ),
284286 v1alpha1 .ReservationNamespaceLabel : reservation .Namespace ,
285287 v1alpha1 .ReservationNameLabel : reservation .Name ,
286288 }
287289
288- for name , fieldPath := range r .DownwardAPILabels {
289- value , err := fieldpath .ExtractFieldPathAsString (reservation , fieldPath )
290- if err != nil {
291- return nil , fmt .Errorf ("error extracting downward api label %q: %w" , name , err )
292- }
293-
294- annotations [v1alpha1 .DownwardAPILabel (name )] = value
290+ apiLabels , err := poolletutils .PrepareDownwardAPILabels (reservation , r .DownwardAPILabels , v1alpha1 .MachineDownwardAPIPrefix )
291+ if err != nil {
292+ return nil , err
295293 }
296- return annotations , nil
294+ labels = utilsmaps .AppendMap (labels , apiLabels )
295+ return labels , nil
297296}
298297
299298func (r * ReservationReconciler ) iriReservationAnnotations (
@@ -308,7 +307,7 @@ func (r *ReservationReconciler) iriReservationAnnotations(
308307 return nil , fmt .Errorf ("error extracting downward api annotation %q: %w" , name , err )
309308 }
310309
311- annotations [v1alpha1 .DownwardAPIAnnotation (name )] = value
310+ annotations [poolletutils .DownwardAPIAnnotation (v1alpha1 . MachineDownwardAPIPrefix , name )] = value
312311 }
313312
314313 return annotations , nil
0 commit comments