@@ -12,6 +12,9 @@ import (
1212 bucketbrokerv1alpha1 "github.com/ironcore-dev/ironcore/broker/bucketbroker/api/v1alpha1"
1313 "github.com/ironcore-dev/ironcore/broker/bucketbroker/apiutils"
1414 iri "github.com/ironcore-dev/ironcore/iri/apis/bucket/v1alpha1"
15+ bucketpoolletv1alpha1 "github.com/ironcore-dev/ironcore/poollet/bucketpoollet/api/v1alpha1"
16+ poolletutils "github.com/ironcore-dev/ironcore/poollet/common/utils"
17+ "github.com/ironcore-dev/ironcore/utils/maps"
1518 corev1 "k8s.io/api/core/v1"
1619 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1720 "sigs.k8s.io/controller-runtime/pkg/client"
@@ -22,17 +25,37 @@ type AggregateIronCoreBucket struct {
2225 AccessSecret * corev1.Secret
2326}
2427
28+ func (s * Server ) prepareIronCoreBucketLabels (bucket * iri.Bucket ) map [string ]string {
29+ labels := make (map [string ]string )
30+
31+ for downwardAPILabelName , defaultLabelName := range s .brokerDownwardAPILabels {
32+ value := bucket .GetMetadata ().GetLabels ()[poolletutils .DownwardAPILabel (bucketpoolletv1alpha1 .BucketDownwardAPIPrefix , downwardAPILabelName )]
33+ if value == "" {
34+ value = bucket .GetMetadata ().GetLabels ()[defaultLabelName ]
35+ }
36+ if value != "" {
37+ labels [poolletutils .DownwardAPILabel (bucketpoolletv1alpha1 .BucketDownwardAPIPrefix , downwardAPILabelName )] = value
38+ }
39+ }
40+
41+ return labels
42+ }
43+
2544func (s * Server ) getIronCoreBucketConfig (_ context.Context , bucket * iri.Bucket ) (* AggregateIronCoreBucket , error ) {
2645 var bucketPoolRef * corev1.LocalObjectReference
2746 if s .bucketPoolName != "" {
2847 bucketPoolRef = & corev1.LocalObjectReference {
2948 Name : s .bucketPoolName ,
3049 }
3150 }
51+ labels := s .prepareIronCoreBucketLabels (bucket )
3252 ironcoreBucket := & storagev1alpha1.Bucket {
3353 ObjectMeta : metav1.ObjectMeta {
3454 Namespace : s .namespace ,
3555 Name : s .generateID (),
56+ Labels : maps .AppendMap (labels , map [string ]string {
57+ bucketbrokerv1alpha1 .ManagerLabel : bucketbrokerv1alpha1 .BucketBrokerManager ,
58+ }),
3659 },
3760 Spec : storagev1alpha1.BucketSpec {
3861 BucketClassRef : & corev1.LocalObjectReference {Name : bucket .Spec .Class },
@@ -43,7 +66,6 @@ func (s *Server) getIronCoreBucketConfig(_ context.Context, bucket *iri.Bucket)
4366 if err := apiutils .SetObjectMetadata (ironcoreBucket , bucket .Metadata ); err != nil {
4467 return nil , err
4568 }
46- apiutils .SetBucketManagerLabel (ironcoreBucket , bucketbrokerv1alpha1 .BucketBrokerManager )
4769
4870 return & AggregateIronCoreBucket {
4971 Bucket : ironcoreBucket ,
0 commit comments