@@ -147,7 +147,7 @@ func (co *consoleOperator) sync_v400(ctx context.Context, controllerContext fact
147
147
}
148
148
149
149
// TODO: why is this missing a toUpdate change?
150
- _ , customLogosErrReason , customLogosErr := co .SyncCustomLogoConfigMaps (ctx , updatedOperatorConfig )
150
+ configMapsToSync , customLogosErrReason , customLogosErr := co .SyncCustomLogoConfigMaps (ctx , updatedOperatorConfig )
151
151
// If the custom logo sync fails for any reason, we are degraded, not progressing.
152
152
// The sync loop may not settle, we are unable to honor it in current state.
153
153
statusHandler .AddConditions (status .HandleProgressingOrDegraded ("CustomLogoSync" , customLogosErrReason , customLogosErr ))
@@ -187,7 +187,7 @@ func (co *consoleOperator) sync_v400(ctx context.Context, controllerContext fact
187
187
sessionSecret ,
188
188
set .Proxy ,
189
189
set .Infrastructure ,
190
- customLogosErr == nil , // TODO update this to accept result of SyncCustomLogoConfigMaps
190
+ configMapsToSync ,
191
191
controllerContext .Recorder (),
192
192
)
193
193
toUpdate = toUpdate || depChanged
@@ -291,7 +291,7 @@ func (co *consoleOperator) SyncDeployment(
291
291
sessionSecret * corev1.Secret ,
292
292
proxyConfig * configv1.Proxy ,
293
293
infrastructureConfig * configv1.Infrastructure ,
294
- canMountCustomLogo bool ,
294
+ customLogos []configmapsub. CustomLogoRef ,
295
295
recorder events.Recorder ,
296
296
) (consoleDeployment * appsv1.Deployment , changed bool , reason string , err error ) {
297
297
updatedOperatorConfig := operatorConfig .DeepCopy ()
@@ -306,7 +306,7 @@ func (co *consoleOperator) SyncDeployment(
306
306
sessionSecret ,
307
307
proxyConfig ,
308
308
infrastructureConfig ,
309
- canMountCustomLogo ,
309
+ customLogos ,
310
310
)
311
311
genChanged := operatorConfig .ObjectMeta .Generation != operatorConfig .Status .ObservedGeneration
312
312
@@ -554,36 +554,31 @@ func (co *consoleOperator) SyncTrustedCAConfigMap(ctx context.Context, operatorC
554
554
return actual , true , "" , err
555
555
}
556
556
557
- type operatorCustomLogo struct {
558
- location operatorv1.LogoType
559
- theme operatorv1.ThemeType
560
- file configv1.ConfigMapFileReference
561
- okToMount bool
562
- }
563
-
564
- func (co * consoleOperator ) SyncCustomLogoConfigMaps (ctx context.Context , operatorConfig * operatorv1.Console ) ([]operatorCustomLogo , string , error ) {
557
+ func (co * consoleOperator ) SyncCustomLogoConfigMaps (ctx context.Context , operatorConfig * operatorv1.Console ) ([]configmapsub.CustomLogoRef , string , error ) {
565
558
configMapsToSync := getConfigMapsToSync (operatorConfig )
566
559
var (
567
- aggregatedError error
568
- aggregatedReason string
560
+ aggregatedError error
561
+ err error
562
+ reason string
569
563
)
570
564
for _ , logoToSync := range configMapsToSync {
571
- reason , err : = co .SyncCustomLogoConfigMap (ctx , logoToSync )
565
+ logoToSync . OkToMount , reason , err = co .SyncCustomLogoConfigMap (ctx , logoToSync )
572
566
if err != nil {
573
567
if aggregatedError == nil {
574
568
aggregatedError = fmt .Errorf ("One or more errors were encountered while configuring custom logos:\n \t - %v, %s" , logoToSync , err .Error ())
575
- aggregatedReason = reason
576
569
} else {
577
570
aggregatedError = fmt .Errorf ("%s\n \t - %v, %s" , aggregatedError .Error (), logoToSync , err .Error ())
578
- aggregatedReason = fmt .Sprintf ("%s, %s" , aggregatedReason , reason )
579
571
}
580
572
}
581
573
}
582
- return configMapsToSync , aggregatedReason , aggregatedError
574
+ if aggregatedError != nil {
575
+ return nil , reason , aggregatedError
576
+ }
577
+ return configMapsToSync , "" , nil
583
578
}
584
579
585
- func getConfigMapsToSync (operatorConfig * operatorv1.Console ) []operatorCustomLogo {
586
- var normalizedLogos = []operatorCustomLogo {}
580
+ func getConfigMapsToSync (operatorConfig * operatorv1.Console ) []configmapsub. CustomLogoRef {
581
+ var normalizedLogos = []configmapsub. CustomLogoRef {}
587
582
var skipDeprecatedLogoSync = false
588
583
if operatorConfig .Spec .Customization .CustomLogos != nil {
589
584
for _ , logo := range operatorConfig .Spec .Customization .CustomLogos {
@@ -593,10 +588,10 @@ func getConfigMapsToSync(operatorConfig *operatorv1.Console) []operatorCustomLog
593
588
for _ , theme := range logo .Themes {
594
589
normalizedLogos = append (
595
590
normalizedLogos ,
596
- operatorCustomLogo {
597
- location : logo .Type ,
598
- theme : theme .Type ,
599
- file : theme .File ,
591
+ configmapsub. CustomLogoRef {
592
+ Location : logo .Type ,
593
+ Theme : theme .Type ,
594
+ File : theme .File ,
600
595
},
601
596
)
602
597
}
@@ -606,10 +601,10 @@ func getConfigMapsToSync(operatorConfig *operatorv1.Console) []operatorCustomLog
606
601
if ! skipDeprecatedLogoSync && & operatorConfig .Spec .Customization .CustomLogoFile != nil {
607
602
normalizedLogos = append (
608
603
normalizedLogos ,
609
- operatorCustomLogo {
610
- location : operatorv1 .LogoTypeMasthead ,
611
- theme : operatorv1 .ThemeTypeDefault ,
612
- file : operatorConfig .Spec .Customization .CustomLogoFile ,
604
+ configmapsub. CustomLogoRef {
605
+ Location : operatorv1 .LogoTypeMasthead ,
606
+ Theme : operatorv1 .ThemeTypeDefault ,
607
+ File : operatorConfig .Spec .Customization .CustomLogoFile ,
613
608
},
614
609
)
615
610
}
@@ -622,18 +617,15 @@ func getConfigMapsToSync(operatorConfig *operatorv1.Console) []operatorCustomLog
622
617
// - Validate existence of custom icon configmaps defined in the console operator config,
623
618
// - populate to the console config
624
619
// - create volumes/volumemounts in console deployment
625
- func (co * consoleOperator ) SyncCustomLogoConfigMap (ctx context.Context , customLogo operatorCustomLogo ) (string , error ) {
620
+ func (co * consoleOperator ) SyncCustomLogoConfigMap (ctx context.Context , customLogo configmapsub. CustomLogoRef ) (bool , string , error ) {
626
621
// validate first, to avoid a broken volume mount & a crashlooping console
627
- okToMount , reason , err := co .ValidateCustomLogo (ctx , customLogo .file )
628
- if customLogo .okToMount {
629
- if err := co .UpdateCustomLogoSyncSource (& customLogo .file ); err != nil {
630
- okToMount = false
631
- reason = "FailedSyncSource"
632
- err = customerrors .NewCustomLogoError ("custom logo sync source update error" )
622
+ okToMount , reason , err := co .ValidateCustomLogo (ctx , customLogo .File )
623
+ if okToMount {
624
+ if err := co .UpdateCustomLogoSyncSource (customLogo .File ); err != nil {
625
+ return false , "FailedSyncSource" , customerrors .NewCustomLogoError (fmt .Sprintf ("custom logo sync source update error, %v" , err ))
633
626
}
634
627
}
635
- customLogo .okToMount = okToMount // TODO get rid of side-effect
636
- return reason , err
628
+ return okToMount , reason , err
637
629
}
638
630
639
631
func (co * consoleOperator ) ValidateOAuthServingCertConfigMap (ctx context.Context ) (oauthServingCert * corev1.ConfigMap , reason string , err error ) {
@@ -657,7 +649,7 @@ func (co *consoleOperator) ValidateOAuthServingCertConfigMap(ctx context.Context
657
649
// sync loop will run later. Our operator is waiting to receive
658
650
// the copied configmap into the console namespace for a future
659
651
// sync loop to mount into the console deployment.
660
- func (c * consoleOperator ) UpdateCustomLogoSyncSource (cmRef * configv1.ConfigMapFileReference ) error {
652
+ func (c * consoleOperator ) UpdateCustomLogoSyncSource (cmRef configv1.ConfigMapFileReference ) error {
661
653
source := resourcesynccontroller.ResourceLocation {}
662
654
logoConfigMapName := cmRef .Name
663
655
0 commit comments