@@ -162,16 +162,16 @@ def installOpenShiftPipelines(dynClient: DynamicClient, customStorageClassName:
162162def enablePipelinesConsolePlugin (dynClient : DynamicClient ) -> bool :
163163 """
164164 Enable the OpenShift Pipelines console plugin for OCP 4.21+.
165-
165+
166166 In OpenShift 4.21 and later, the Pipelines console plugin must be manually
167167 enabled by patching the Console operator configuration. This function:
168168 1. Detects the OCP version
169169 2. Checks if version >= 4.21
170170 3. Enables the plugin if not already enabled
171-
171+
172172 Parameters:
173173 dynClient (DynamicClient): OpenShift Dynamic Client
174-
174+
175175 Returns:
176176 bool: True if plugin is enabled or already enabled, False on error
177177 """
@@ -181,63 +181,63 @@ def enablePipelinesConsolePlugin(dynClient: DynamicClient) -> bool:
181181 if not clusterVersion :
182182 logger .warning ("Unable to determine cluster version, skipping plugin enablement" )
183183 return True # Non-fatal, return True to continue
184-
184+
185185 logger .debug (f"Detected OpenShift version: { clusterVersion } " )
186-
186+
187187 # Parse version (e.g., "4.21.0" -> major=4, minor=21)
188188 versionParts = clusterVersion .split ('.' )
189189 if len (versionParts ) < 2 :
190190 logger .warning (f"Unable to parse cluster version '{ clusterVersion } ', skipping plugin enablement" )
191191 return True
192-
192+
193193 try :
194194 majorVersion = int (versionParts [0 ])
195195 minorVersion = int (versionParts [1 ])
196196 except ValueError :
197197 logger .warning (f"Unable to parse version numbers from '{ clusterVersion } ', skipping plugin enablement" )
198198 return True
199-
199+
200200 # Check if version requires plugin enablement (4.21+)
201201 requiresPlugin = (majorVersion == 4 and minorVersion >= 21 ) or (majorVersion > 4 )
202-
202+
203203 if not requiresPlugin :
204204 logger .info (f"OpenShift version { clusterVersion } does not require manual plugin enablement" )
205205 return True
206-
206+
207207 logger .info (f"OpenShift version { clusterVersion } requires Pipelines console plugin to be enabled" )
208-
208+
209209 # Get Console Operator
210210 consoleAPI = dynClient .resources .get (api_version = "operator.openshift.io/v1" , kind = "Console" )
211211 console = consoleAPI .get (name = "cluster" )
212-
212+
213213 # Check if plugin is already enabled
214214 currentPlugins = console .spec .plugins if hasattr (console .spec , 'plugins' ) and console .spec .plugins else []
215215 pluginName = "pipelines-console-plugin"
216-
216+
217217 if pluginName in currentPlugins :
218218 logger .info (f"Pipelines console plugin is already enabled" )
219219 return True
220-
220+
221221 # Enable the plugin by patching the Console operator
222222 logger .info (f"Enabling Pipelines console plugin..." )
223-
223+
224224 # Create patch to add plugin to the list
225225 updatedPlugins = list (currentPlugins ) + [pluginName ]
226226 patch = {
227227 "spec" : {
228228 "plugins" : updatedPlugins
229229 }
230230 }
231-
231+
232232 consoleAPI .patch (
233233 name = "cluster" ,
234234 body = patch ,
235235 content_type = "application/merge-patch+json"
236236 )
237-
237+
238238 logger .info (f"Successfully enabled Pipelines console plugin" )
239239 return True
240-
240+
241241 except NotFoundError as e :
242242 logger .warning (f"Console operator not found: { e } " )
243243 return True # Non-fatal, plugin can be enabled manually
0 commit comments