1010
1111import logging
1212import yaml
13+ import base64
1314
1415from datetime import datetime
1516from os import path
@@ -402,12 +403,12 @@ def prepareInstallSecrets(dynClient: DynamicClient, namespace: str, slsLicenseFi
402403 """
403404 Create or update secrets required for MAS installation pipelines.
404405
405- Creates four secrets in the specified namespace: pipeline-additional-configs,
406+ Creates five secrets in the specified namespace: mas-devops, pipeline-additional-configs,
406407 pipeline-sls-entitlement, pipeline-certificates, and pipeline-pod-templates.
407408
408409 Parameters:
409410 dynClient (DynamicClient): OpenShift Dynamic Client
410- namespace (str): The namespace to create secrets in
411+ namespace (str): The namespace to create secrets in (format: mas-{instance_id}-pipelines)
411412 slsLicenseFile (str, optional): SLS license file content. Defaults to None (empty secret).
412413 additionalConfigs (dict, optional): Additional configuration data. Defaults to None (empty secret).
413414 certs (str, optional): Certificate data. Defaults to None (empty secret).
@@ -421,6 +422,29 @@ def prepareInstallSecrets(dynClient: DynamicClient, namespace: str, slsLicenseFi
421422 """
422423 secretsAPI = dynClient .resources .get (api_version = "v1" , kind = "Secret" )
423424
425+ # Extract instance ID from namespace (format: mas-{instance_id}-pipelines)
426+ instance_id = None
427+ if namespace .startswith ("mas-" ) and namespace .endswith ("-pipelines" ):
428+ instance_id = namespace [4 :- 10 ] # Remove "mas-" prefix and "-pipelines" suffix
429+
430+ # 0. Secret/mas-devops
431+ # -------------------------------------------------------------------------
432+ # Create mas-devops secret with MAS_INSTANCE_ID key
433+ if instance_id :
434+ mas_devops_secret = {
435+ "apiVersion" : "v1" ,
436+ "kind" : "Secret" ,
437+ "type" : "Opaque" ,
438+ "metadata" : {
439+ "name" : "mas-devops"
440+ },
441+ "data" : {
442+ "MAS_INSTANCE_ID" : base64 .b64encode (instance_id .encode ()).decode ()
443+ }
444+ }
445+ secretsAPI .create (body = mas_devops_secret , namespace = namespace )
446+ logger .info (f"Created mas-devops secret with MAS_INSTANCE_ID={ instance_id } in namespace { namespace } " )
447+
424448 # 1. Secret/pipeline-additional-configs
425449 # -------------------------------------------------------------------------
426450 # Must exist, but can be empty
0 commit comments