@@ -255,8 +255,14 @@ func (d *driver) CreateStorage(cr *imageregistryv1.Config) error {
255
255
bucketAttrs := gstorage.BucketAttrs {Location : d .Config .Region }
256
256
bucket = gclient .Bucket (d .Config .Bucket )
257
257
258
- err := bucket . Create (d .Context , d . Config . ProjectID , & bucketAttrs )
258
+ labels , err := getUserLabels (d .Listers . Infrastructures )
259
259
if err != nil {
260
+ return err
261
+ }
262
+ klog .V (1 ).Infof ("createStorage: %v list of labels will be applied to %s bucket" , labels , d .Config .Bucket )
263
+ bucketAttrs .Labels = labels
264
+
265
+ if err := bucket .Create (d .Context , d .Config .ProjectID , & bucketAttrs ); err != nil {
260
266
if gerr , ok := err .(* gapi.Error ); ok {
261
267
util .UpdateCondition (cr , defaults .StorageExists , operatorapi .ConditionFalse , strconv .Itoa (gerr .Code ), gerr .Error ())
262
268
return err
@@ -275,6 +281,10 @@ func (d *driver) CreateStorage(cr *imageregistryv1.Config) error {
275
281
cr .Spec .Storage .GCS = d .Config .DeepCopy ()
276
282
277
283
util .UpdateCondition (cr , defaults .StorageExists , operatorapi .ConditionTrue , "Creation Successful" , "GCS bucket was successfully created" )
284
+ if len (bucketAttrs .Labels ) > 0 {
285
+ util .UpdateCondition (cr , defaults .StorageLabeled , operatorapi .ConditionTrue , "Bucket Labeled Successfully" ,
286
+ fmt .Sprintf ("Successfully added user-defined labels to %s storage bucket" , d .Config .Bucket ))
287
+ }
278
288
}
279
289
280
290
// TODO: Wait until the bucket exists
0 commit comments