@@ -69,12 +69,12 @@ func ReconcileConsoleDeployment(h *common_helper.Helper, ctx context.Context, in
6969}
7070
7171// reconcileConsoleConfigMap ensures the console plugin nginx ConfigMap exists.
72- func reconcileConsoleConfigMap (h * common_helper.Helper , ctx context.Context , _ * apiv1beta1.OpenStackLightspeed ) error {
72+ func reconcileConsoleConfigMap (h * common_helper.Helper , ctx context.Context , instance * apiv1beta1.OpenStackLightspeed ) error {
7373 logger := h .GetLogger ()
7474
7575 cm := & corev1.ConfigMap {
7676 ObjectMeta : metav1.ObjectMeta {
77- Name : ConsoleUIConfigMapName ,
77+ Name : ConsoleUIConfigMapName ( instance . Name ) ,
7878 Namespace : h .GetBeforeObject ().GetNamespace (),
7979 },
8080 }
@@ -95,18 +95,18 @@ func reconcileConsoleConfigMap(h *common_helper.Helper, ctx context.Context, _ *
9595}
9696
9797// reconcileConsoleNetworkPolicy ensures the console plugin network policy exists.
98- func reconcileConsoleNetworkPolicy (h * common_helper.Helper , ctx context.Context , _ * apiv1beta1.OpenStackLightspeed ) error {
98+ func reconcileConsoleNetworkPolicy (h * common_helper.Helper , ctx context.Context , instance * apiv1beta1.OpenStackLightspeed ) error {
9999 logger := h .GetLogger ()
100100
101101 np := & networkingv1.NetworkPolicy {
102102 ObjectMeta : metav1.ObjectMeta {
103- Name : ConsoleUINetworkPolicyName ,
103+ Name : ConsoleUINetworkPolicyName ( instance . Name ) ,
104104 Namespace : h .GetBeforeObject ().GetNamespace (),
105105 },
106106 }
107107
108108 result , err := controllerutil .CreateOrPatch (ctx , h .GetClient (), np , func () error {
109- np .Spec = buildConsoleNetworkPolicySpec ()
109+ np .Spec = buildConsoleNetworkPolicySpec (instance . Name )
110110 return controllerutil .SetControllerReference (h .GetBeforeObject (), np , h .GetScheme ())
111111 })
112112
@@ -119,12 +119,12 @@ func reconcileConsoleNetworkPolicy(h *common_helper.Helper, ctx context.Context,
119119}
120120
121121// reconcileConsoleServiceAccount ensures the console plugin service account exists.
122- func reconcileConsoleServiceAccount (h * common_helper.Helper , ctx context.Context , _ * apiv1beta1.OpenStackLightspeed ) error {
122+ func reconcileConsoleServiceAccount (h * common_helper.Helper , ctx context.Context , instance * apiv1beta1.OpenStackLightspeed ) error {
123123 logger := h .GetLogger ()
124124
125125 sa := & corev1.ServiceAccount {
126126 ObjectMeta : metav1.ObjectMeta {
127- Name : ConsoleUIServiceAccountName ,
127+ Name : ConsoleUIServiceAccountName ( instance . Name ) ,
128128 Namespace : h .GetBeforeObject ().GetNamespace (),
129129 },
130130 }
@@ -181,20 +181,20 @@ func resolveConsoleImage(ctx context.Context, h *common_helper.Helper) string {
181181}
182182
183183// reconcileConsoleDeploymentResource ensures the console plugin deployment exists.
184- func reconcileConsoleDeploymentResource (h * common_helper.Helper , ctx context.Context , _ * apiv1beta1.OpenStackLightspeed ) error {
184+ func reconcileConsoleDeploymentResource (h * common_helper.Helper , ctx context.Context , instance * apiv1beta1.OpenStackLightspeed ) error {
185185 logger := h .GetLogger ()
186186
187187 consoleImage := resolveConsoleImage (ctx , h )
188188
189189 deployment := & appsv1.Deployment {
190190 ObjectMeta : metav1.ObjectMeta {
191- Name : ConsoleUIDeploymentName ,
191+ Name : ConsoleUIDeploymentName ( instance . Name ) ,
192192 Namespace : h .GetBeforeObject ().GetNamespace (),
193193 },
194194 }
195195
196196 result , err := controllerutil .CreateOrPatch (ctx , h .GetClient (), deployment , func () error {
197- spec := buildConsoleDeploymentSpec (consoleImage )
197+ spec := buildConsoleDeploymentSpec (instance . Name , consoleImage )
198198 deployment .Spec .Replicas = spec .Replicas
199199 deployment .Spec .Selector = spec .Selector
200200 deployment .Spec .Template = spec .Template
@@ -210,18 +210,18 @@ func reconcileConsoleDeploymentResource(h *common_helper.Helper, ctx context.Con
210210}
211211
212212// reconcileConsoleService ensures the console plugin service exists.
213- func reconcileConsoleService (h * common_helper.Helper , ctx context.Context , _ * apiv1beta1.OpenStackLightspeed ) error {
213+ func reconcileConsoleService (h * common_helper.Helper , ctx context.Context , instance * apiv1beta1.OpenStackLightspeed ) error {
214214 logger := h .GetLogger ()
215215
216216 svc := & corev1.Service {
217217 ObjectMeta : metav1.ObjectMeta {
218- Name : ConsoleUIServiceName ,
218+ Name : ConsoleUIServiceName ( instance . Name ) ,
219219 Namespace : h .GetBeforeObject ().GetNamespace (),
220220 },
221221 }
222222
223223 result , err := controllerutil .CreateOrPatch (ctx , h .GetClient (), svc , func () error {
224- svc .Spec .Selector = generateConsoleSelectorLabels ()
224+ svc .Spec .Selector = generateConsoleSelectorLabels (instance . Name )
225225 svc .Spec .Ports = []corev1.ServicePort {
226226 {
227227 Port : ConsoleUIHTTPSPort ,
@@ -235,7 +235,7 @@ func reconcileConsoleService(h *common_helper.Helper, ctx context.Context, _ *ap
235235 if svc .Annotations == nil {
236236 svc .Annotations = make (map [string ]string )
237237 }
238- svc .Annotations [ServingCertSecretAnnotationKey ] = ConsoleUIServiceCertSecretName
238+ svc .Annotations [ServingCertSecretAnnotationKey ] = ConsoleUIServiceCertSecretName ( instance . Name )
239239
240240 return controllerutil .SetControllerReference (h .GetBeforeObject (), svc , h .GetScheme ())
241241 })
@@ -250,12 +250,12 @@ func reconcileConsoleService(h *common_helper.Helper, ctx context.Context, _ *ap
250250
251251// reconcileConsoleTLSSecret waits for the console TLS secret to be populated by
252252// the service-ca operator.
253- func reconcileConsoleTLSSecret (h * common_helper.Helper , ctx context.Context , _ * apiv1beta1.OpenStackLightspeed ) error {
253+ func reconcileConsoleTLSSecret (h * common_helper.Helper , ctx context.Context , instance * apiv1beta1.OpenStackLightspeed ) error {
254254 logger := h .GetLogger ()
255- logger .Info ("waiting for console TLS secret" , "name" , ConsoleUIServiceCertSecretName )
255+ logger .Info ("waiting for console TLS secret" , "name" , ConsoleUIServiceCertSecretName ( instance . Name ) )
256256
257257 secretKey := client.ObjectKey {
258- Name : ConsoleUIServiceCertSecretName ,
258+ Name : ConsoleUIServiceCertSecretName ( instance . Name ) ,
259259 Namespace : h .GetBeforeObject ().GetNamespace (),
260260 }
261261
@@ -275,23 +275,23 @@ func reconcileConsoleTLSSecret(h *common_helper.Helper, ctx context.Context, _ *
275275 return fmt .Errorf ("%w: %v" , ErrReconcileConsoleTLSSecret , err )
276276 }
277277
278- logger .Info ("Console TLS secret is ready" , "name" , ConsoleUIServiceCertSecretName )
278+ logger .Info ("Console TLS secret is ready" , "name" , ConsoleUIServiceCertSecretName ( instance . Name ) )
279279 return nil
280280}
281281
282282// reconcileConsolePlugin ensures the ConsolePlugin CR exists.
283- func reconcileConsolePlugin (h * common_helper.Helper , ctx context.Context , _ * apiv1beta1.OpenStackLightspeed ) error {
283+ func reconcileConsolePlugin (h * common_helper.Helper , ctx context.Context , instance * apiv1beta1.OpenStackLightspeed ) error {
284284 logger := h .GetLogger ()
285285 namespace := h .GetBeforeObject ().GetNamespace ()
286286
287287 plugin := & consolev1.ConsolePlugin {
288288 ObjectMeta : metav1.ObjectMeta {
289- Name : ConsoleUIPluginName ,
289+ Name : ConsoleUIPluginName ( instance . Name ) ,
290290 },
291291 }
292292
293293 result , err := controllerutil .CreateOrPatch (ctx , h .GetClient (), plugin , func () error {
294- plugin .Spec = buildConsolePluginSpec (namespace )
294+ plugin .Spec = buildConsolePluginSpec (instance . Name , namespace )
295295 // ConsolePlugin is cluster-scoped, no owner reference
296296 return nil
297297 })
@@ -305,8 +305,9 @@ func reconcileConsolePlugin(h *common_helper.Helper, ctx context.Context, _ *api
305305}
306306
307307// activateConsole adds the console plugin to the Console CR's plugin list.
308- func activateConsole (h * common_helper.Helper , ctx context.Context , _ * apiv1beta1.OpenStackLightspeed ) error {
308+ func activateConsole (h * common_helper.Helper , ctx context.Context , instance * apiv1beta1.OpenStackLightspeed ) error {
309309 logger := h .GetLogger ()
310+ pluginName := ConsoleUIPluginName (instance .Name )
310311
311312 err := retry .RetryOnConflict (retry .DefaultRetry , func () error {
312313 console := & openshiftv1.Console {}
@@ -320,9 +321,9 @@ func activateConsole(h *common_helper.Helper, ctx context.Context, _ *apiv1beta1
320321 }
321322
322323 if console .Spec .Plugins == nil {
323- console .Spec .Plugins = []string {ConsoleUIPluginName }
324- } else if ! slices .Contains (console .Spec .Plugins , ConsoleUIPluginName ) {
325- console .Spec .Plugins = append (console .Spec .Plugins , ConsoleUIPluginName )
324+ console .Spec .Plugins = []string {pluginName }
325+ } else if ! slices .Contains (console .Spec .Plugins , pluginName ) {
326+ console .Spec .Plugins = append (console .Spec .Plugins , pluginName )
326327 } else {
327328 return nil
328329 }
@@ -338,8 +339,9 @@ func activateConsole(h *common_helper.Helper, ctx context.Context, _ *apiv1beta1
338339}
339340
340341// reconcileDeleteConsole deactivates the console plugin and deletes the ConsolePlugin CR.
341- func reconcileDeleteConsole (h * common_helper.Helper , ctx context.Context , _ * apiv1beta1.OpenStackLightspeed ) error {
342+ func reconcileDeleteConsole (h * common_helper.Helper , ctx context.Context , instance * apiv1beta1.OpenStackLightspeed ) error {
342343 logger := h .GetLogger ()
344+ pluginName := ConsoleUIPluginName (instance .Name )
343345
344346 // Deactivate: remove plugin from Console CR
345347 err := retry .RetryOnConflict (retry .DefaultRetry , func () error {
@@ -356,12 +358,12 @@ func reconcileDeleteConsole(h *common_helper.Helper, ctx context.Context, _ *api
356358 if console .Spec .Plugins == nil {
357359 return nil
358360 }
359- if ! slices .Contains (console .Spec .Plugins , ConsoleUIPluginName ) {
361+ if ! slices .Contains (console .Spec .Plugins , pluginName ) {
360362 return nil
361363 }
362364
363365 console .Spec .Plugins = slices .DeleteFunc (console .Spec .Plugins , func (name string ) bool {
364- return name == ConsoleUIPluginName
366+ return name == pluginName
365367 })
366368
367369 return h .GetClient ().Update (ctx , console )
@@ -373,7 +375,7 @@ func reconcileDeleteConsole(h *common_helper.Helper, ctx context.Context, _ *api
373375
374376 // Delete ConsolePlugin CR
375377 plugin := & consolev1.ConsolePlugin {}
376- err = h .GetClient ().Get (ctx , client.ObjectKey {Name : ConsoleUIPluginName }, plugin )
378+ err = h .GetClient ().Get (ctx , client.ObjectKey {Name : pluginName }, plugin )
377379 if err != nil {
378380 if errors .IsNotFound (err ) {
379381 logger .Info ("ConsolePlugin not found, skip deletion" )
0 commit comments