@@ -114,6 +114,22 @@ func (co *consoleOperator) sync_v400(ctx context.Context, controllerContext fact
114
114
}
115
115
}
116
116
117
+ // TODO remove deprecated CustomLogoFile API
118
+ // TODO: why is this missing a toUpdate change?
119
+ customLogoError , customLogoErrReason := co .SyncCustomLogoConfigMap (updatedOperatorConfig )
120
+ // If the custom logo sync fails for any reason, we are degraded, not progressing.
121
+ // The sync loop may not settle, we are unable to honor it in current state.
122
+ statusHandler .AddConditions (status .HandleProgressingOrDegraded ("CustomLogoSync" , customLogoErrReason , customLogoError ))
123
+ if customLogoError != nil {
124
+ return statusHandler .FlushAndReturn (customLogoError )
125
+ }
126
+
127
+ customLogosErr , customLogosErrReason := co .SyncCustomLogos (updatedOperatorConfig )
128
+ statusHandler .AddConditions (status .HandleProgressingOrDegraded ("CustomLogosSync" , customLogosErrReason , customLogosErr ))
129
+ if customLogosErr != nil {
130
+ return statusHandler .FlushAndReturn (customLogosErr )
131
+ }
132
+
117
133
cm , cmChanged , cmErrReason , cmErr := co .SyncConfigMap (
118
134
ctx ,
119
135
set .Operator ,
@@ -146,15 +162,6 @@ func (co *consoleOperator) sync_v400(ctx context.Context, controllerContext fact
146
162
return statusHandler .FlushAndReturn (trustedCAErr )
147
163
}
148
164
149
- // TODO: why is this missing a toUpdate change?
150
- customLogoCanMount , customLogoErrReason , customLogoError := co .SyncCustomLogoConfigMap (ctx , updatedOperatorConfig )
151
- // If the custom logo sync fails for any reason, we are degraded, not progressing.
152
- // The sync loop may not settle, we are unable to honor it in current state.
153
- statusHandler .AddConditions (status .HandleProgressingOrDegraded ("CustomLogoSync" , customLogoErrReason , customLogoError ))
154
- if customLogoError != nil {
155
- return statusHandler .FlushAndReturn (customLogoError )
156
- }
157
-
158
165
var oauthServingCertConfigMap * corev1.ConfigMap
159
166
switch authnConfig .Spec .Type {
160
167
// We don't disable auth since the internal OAuth server is not disabled even with auth type 'None'.
@@ -187,7 +194,6 @@ func (co *consoleOperator) sync_v400(ctx context.Context, controllerContext fact
187
194
sessionSecret ,
188
195
set .Proxy ,
189
196
set .Infrastructure ,
190
- customLogoCanMount ,
191
197
controllerContext .Recorder (),
192
198
)
193
199
toUpdate = toUpdate || depChanged
@@ -291,7 +297,6 @@ func (co *consoleOperator) SyncDeployment(
291
297
sessionSecret * corev1.Secret ,
292
298
proxyConfig * configv1.Proxy ,
293
299
infrastructureConfig * configv1.Infrastructure ,
294
- canMountCustomLogo bool ,
295
300
recorder events.Recorder ,
296
301
) (consoleDeployment * appsv1.Deployment , changed bool , reason string , err error ) {
297
302
updatedOperatorConfig := operatorConfig .DeepCopy ()
@@ -306,7 +311,6 @@ func (co *consoleOperator) SyncDeployment(
306
311
sessionSecret ,
307
312
proxyConfig ,
308
313
infrastructureConfig ,
309
- canMountCustomLogo ,
310
314
)
311
315
genChanged := operatorConfig .ObjectMeta .Generation != operatorConfig .Status .ObservedGeneration
312
316
@@ -554,16 +558,35 @@ func (co *consoleOperator) SyncTrustedCAConfigMap(ctx context.Context, operatorC
554
558
return actual , true , "" , err
555
559
}
556
560
557
- func (co * consoleOperator ) SyncCustomLogoConfigMap (ctx context.Context , operatorConfig * operatorv1.Console ) (okToMount bool , reason string , err error ) {
558
- // validate first, to avoid a broken volume mount & a crashlooping console
559
- okToMount , reason , err = co .ValidateCustomLogo (ctx , operatorConfig )
560
-
561
- if okToMount || configmapsub .IsRemoved (operatorConfig ) {
562
- if err := co .UpdateCustomLogoSyncSource (operatorConfig ); err != nil {
563
- return false , "FailedSyncSource" , customerrors .NewCustomLogoError ("custom logo sync source update error" )
561
+ func (co * consoleOperator ) SyncCustomLogos (operatorConfig * operatorv1.Console ) (error , string ) {
562
+ var (
563
+ aggregatedError error
564
+ err error
565
+ reason string
566
+ )
567
+ for _ , logo := range operatorConfig .Spec .Customization .Logos {
568
+ for _ , theme := range logo .Themes {
569
+ logoToSync := theme .Source .ConfigMap
570
+ err , reason = co .UpdateCustomLogoSyncSource (logoToSync )
571
+ if err != nil {
572
+ if aggregatedError == nil {
573
+ aggregatedError = fmt .Errorf ("One or more errors were encountered while syncing custom logos:\n - %v, %s" , logoToSync , err .Error ())
574
+ } else {
575
+ aggregatedError = fmt .Errorf ("%s\n - %v, %s" , aggregatedError .Error (), logoToSync , err .Error ())
576
+ }
577
+ }
564
578
}
565
579
}
566
- return okToMount , reason , err
580
+ if aggregatedError != nil {
581
+ return aggregatedError , reason
582
+ }
583
+ return nil , ""
584
+ }
585
+
586
+ // TODO remove deprecated CustomLogoFile API
587
+ func (co * consoleOperator ) SyncCustomLogoConfigMap (operatorConfig * operatorv1.Console ) (error , string ) {
588
+ var customLogoRef = operatorv1 .ConfigMapFileReference (operatorConfig .Spec .Customization .CustomLogoFile )
589
+ return co .UpdateCustomLogoSyncSource (& customLogoRef )
567
590
}
568
591
569
592
func (co * consoleOperator ) ValidateOAuthServingCertConfigMap (ctx context.Context ) (oauthServingCert * corev1.ConfigMap , reason string , err error ) {
@@ -587,39 +610,52 @@ func (co *consoleOperator) ValidateOAuthServingCertConfigMap(ctx context.Context
587
610
// sync loop will run later. Our operator is waiting to receive
588
611
// the copied configmap into the console namespace for a future
589
612
// sync loop to mount into the console deployment.
590
- func (c * consoleOperator ) UpdateCustomLogoSyncSource (operatorConfig * operatorv1.Console ) error {
613
+ func (c * consoleOperator ) UpdateCustomLogoSyncSource (cmRef * operatorv1.ConfigMapFileReference ) (error , string ) {
614
+ // validate first, to avoid a broken volume mount & a crashlooping console
615
+ err , reason := c .ValidateCustomLogo (cmRef )
616
+ if err != nil {
617
+ return err , reason
618
+ }
619
+
591
620
source := resourcesynccontroller.ResourceLocation {}
592
- logoConfigMapName := operatorConfig . Spec . Customization . CustomLogoFile .Name
621
+ logoConfigMapName := cmRef .Name
593
622
594
623
if logoConfigMapName != "" {
595
624
source .Name = logoConfigMapName
596
625
source .Namespace = api .OpenShiftConfigNamespace
597
626
}
598
627
// if no custom logo provided, sync an empty source to delete
599
- return c .resourceSyncer .SyncConfigMap (
600
- resourcesynccontroller.ResourceLocation {Namespace : api .OpenShiftConsoleNamespace , Name : api . OpenShiftCustomLogoConfigMapName },
628
+ err = c .resourceSyncer .SyncConfigMap (
629
+ resourcesynccontroller.ResourceLocation {Namespace : api .OpenShiftConsoleNamespace , Name : cmRef . Name },
601
630
source ,
602
631
)
632
+ if err != nil {
633
+ return err , "FailedResourceSync"
634
+ }
635
+
636
+ return nil , ""
603
637
}
604
638
605
- func (co * consoleOperator ) ValidateCustomLogo (ctx context. Context , operatorConfig * operatorv1.Console ) (okToMount bool , reason string , err error ) {
606
- logoConfigMapName := operatorConfig . Spec . Customization . CustomLogoFile .Name
607
- logoImageKey := operatorConfig . Spec . Customization . CustomLogoFile .Key
639
+ func (co * consoleOperator ) ValidateCustomLogo (logoFileRef * operatorv1.ConfigMapFileReference ) (err error , reason string ) {
640
+ logoConfigMapName := logoFileRef .Name
641
+ logoImageKey := logoFileRef .Key
608
642
609
- if configmapsub . FileNameOrKeyInconsistentlySet ( operatorConfig ) {
643
+ if ( len ( logoConfigMapName ) == 0 ) != ( len ( logoImageKey ) == 0 ) {
610
644
klog .V (4 ).Infoln ("custom logo filename or key have not been set" )
611
- return false , "KeyOrFilenameInvalid" , customerrors .NewCustomLogoError ("either custom logo filename or key have not been set" )
645
+ return customerrors .NewCustomLogoError ("either custom logo filename or key have not been set" ), "KeyOrFilenameInvalid"
612
646
}
647
+
613
648
// fine if nothing set, but don't mount it
614
- if configmapsub . FileNameNotSet ( operatorConfig ) {
649
+ if len ( logoConfigMapName ) == 0 {
615
650
klog .V (4 ).Infoln ("no custom logo configured" )
616
- return false , "" , nil
651
+ return nil , ""
617
652
}
653
+
618
654
logoConfigMap , err := co .configNSConfigMapLister .ConfigMaps (api .OpenShiftConfigNamespace ).Get (logoConfigMapName )
619
655
// If we 404, the logo file may not have been created yet.
620
656
if err != nil {
621
- klog .V (4 ).Infof ("custom logo file %v not found " , logoConfigMapName )
622
- return false , "FailedGet" , customerrors .NewCustomLogoError (fmt .Sprintf ("custom logo file %v not found " , logoConfigMapName ))
657
+ klog .V (4 ).Infof ("failed to get ConfigMap %v, %v " , logoConfigMapName , err )
658
+ return customerrors .NewCustomLogoError (fmt .Sprintf ("failed to get ConfigMap %v, %v " , logoConfigMapName , err )), "FailedGet"
623
659
}
624
660
625
661
_ , imageDataFound := logoConfigMap .BinaryData [logoImageKey ]
@@ -628,11 +664,11 @@ func (co *consoleOperator) ValidateCustomLogo(ctx context.Context, operatorConfi
628
664
}
629
665
if ! imageDataFound {
630
666
klog .V (4 ).Infoln ("custom logo file exists but no image provided" )
631
- return false , "NoImageProvided" , customerrors .NewCustomLogoError ("custom logo file exists but no image provided" )
667
+ return customerrors .NewCustomLogoError ("custom logo file exists but no image provided" ), "NoImageProvided"
632
668
}
633
669
634
- klog .V (4 ).Infoln ("custom logo ok to mount" )
635
- return true , "" , nil
670
+ klog .V (4 ).Infof ("custom logo %s ok to mount" , logoConfigMapName )
671
+ return nil , ""
636
672
}
637
673
638
674
func (co * consoleOperator ) GetAvailablePlugins (enabledPluginsNames []string ) []* v1.ConsolePlugin {
0 commit comments