@@ -459,6 +459,7 @@ private async Task ResourceReflect(NamespacedName sourceNsName, NamespacedName r
459
459
source = sourceObj ;
460
460
}
461
461
462
+ var sourceProperties = source . GetMirroringProperties ( ) ;
462
463
463
464
var patchAnnotations = new Dictionary < string , string >
464
465
{
@@ -487,6 +488,17 @@ private async Task ResourceReflect(NamespacedName sourceNsName, NamespacedName r
487
488
newResourceAnnotations [ Annotations . Reflection . MetaReflectedVersion ] = source . Metadata . ResourceVersion ;
488
489
newResourceAnnotations [ Annotations . Reflection . MetaReflectedAt ] = DateTimeOffset . UtcNow . ToString ( "O" ) ;
489
490
491
+ if ( sourceProperties . Labels )
492
+ {
493
+ newResource . Metadata . Labels ??= new Dictionary < string , string > ( ) ;
494
+ var newResourceLabels = newResource . Metadata . Labels ;
495
+ foreach ( var label in source . Metadata . Labels )
496
+ {
497
+ if ( sourceProperties . CanLabelBeReflected ( label . Key ) )
498
+ newResourceLabels [ label . Key ] = label . Value ;
499
+ }
500
+ }
501
+
490
502
try
491
503
{
492
504
await OnResourceCreate ( newResource , reflectionNsName . Namespace ) ;
@@ -515,6 +527,19 @@ private async Task ResourceReflect(NamespacedName sourceNsName, NamespacedName r
515
527
annotations [ patchAnnotation . Key ] = patchAnnotation . Value ;
516
528
patchDoc . Replace ( e => e . Metadata . Annotations , annotations ) ;
517
529
530
+ if ( sourceProperties . Labels && source . Metadata . Labels != null )
531
+ {
532
+ var labels = new Dictionary < string , string > ( ) ;
533
+ if ( reflectionObj . Metadata . Labels != null )
534
+ labels = new Dictionary < string , string > ( reflectionObj . Metadata . Labels ) ;
535
+ foreach ( var label in source . Metadata . Labels )
536
+ {
537
+ if ( sourceProperties . CanLabelBeReflected ( label . Key ) )
538
+ labels [ label . Key ] = label . Value ;
539
+ }
540
+ patchDoc . Replace ( e => e . Metadata . Labels , labels ) ;
541
+ }
542
+
518
543
await OnResourceConfigurePatch ( source , patchDoc ) ;
519
544
520
545
var patch = JsonConvert . SerializeObject ( patchDoc , Formatting . Indented ) ;
0 commit comments