33"""This pipeline script knows about the details of our Docker images
44and where to fetch and calculate parameters. It uses Sonar.py
55to produce the final images."""
6+ from .build_context import BuildScenario
67
78# TODO: test pipeline, e.g with a test registry
89
@@ -274,7 +275,7 @@ def build_tests_image(build_configuration: BuildConfiguration):
274275
275276 pipeline_process_image (
276277 image_name ,
277- image_tag = image_tag ,
278+ image_tag = build_configuration . version ,
278279 dockerfile_path = "Dockerfile" ,
279280 dockerfile_args = buildargs ,
280281 base_registry = build_configuration .base_registry ,
@@ -527,8 +528,7 @@ def build_init_appdb(build_configuration: BuildConfiguration):
527528 version = release ["initAppDbVersion" ]
528529 base_url = "https://fastdl.mongodb.org/tools/db/"
529530 mongodb_tools_url_ubi = "{}{}" .format (base_url , release ["mongodbToolsBundle" ]["ubi" ])
530- version , _ = get_git_release_tag () # TODO: check how to properly retrieve version
531- args = {"version" : version , "is_appdb" : True , "mongodb_tools_url_ubi" : mongodb_tools_url_ubi }
531+ args = {"version" : version , "mongodb_tools_url_ubi" : mongodb_tools_url_ubi }
532532 build_image_generic (
533533 image_name = "mongodb-kubernetes-init-appdb" ,
534534 dockerfile_path = "docker/mongodb-kubernetes-init-appdb/Dockerfile" ,
@@ -556,7 +556,7 @@ def build_community_image(build_configuration: BuildConfiguration, image_type: s
556556 else :
557557 raise ValueError (f"Unsupported image type: { image_type } " )
558558
559- version , is_release = get_git_release_tag ()
559+ version = build_configuration . version
560560 golang_version = os .getenv ("GOLANG_VERSION" , "1.24" )
561561
562562 # Use only amd64 if we should skip arm64 builds
@@ -611,10 +611,6 @@ def build_agent_pipeline(
611611):
612612 version = f"{ agent_version } _{ image_version } "
613613
614- quay_agent_registry = (
615- f"{ build_configuration .base_registry } /mongodb-agent-ubi"
616- )
617-
618614 args = {
619615 "version" : version ,
620616 "agent_version" : agent_version ,
@@ -623,13 +619,13 @@ def build_agent_pipeline(
623619 "init_database_image" : init_database_image ,
624620 "mongodb_tools_url_ubi" : mongodb_tools_url_ubi ,
625621 "mongodb_agent_url_ubi" : mongodb_agent_url_ubi ,
626- "quay_registry" : quay_agent_registry ,
622+ "quay_registry" : build_configuration . base_registry ,
627623 }
628624
629625 build_image_generic (
630626 image_name = "mongodb-agent-ubi" ,
631627 dockerfile_path = "docker/mongodb-agent/Dockerfile" ,
632- registry_address = quay_agent_registry ,
628+ registry_address = build_configuration . base_registry ,
633629 extra_args = args ,
634630 sign = build_configuration .sign ,
635631 )
@@ -696,16 +692,14 @@ def build_agent_default_case(build_configuration: BuildConfiguration):
696692 """
697693 release = load_release_file ()
698694
699- operator_version , is_release = get_git_release_tag ()
700-
701695 # We need to release [all agents x latest operator] on operator releases
702- if is_release :
696+ if build_configuration . scenario == BuildScenario . RELEASE :
703697 agent_versions_to_build = gather_all_supported_agent_versions (release )
704698 # We only need [latest agents (for each OM major version and for CM) x patch ID] for patches
705699 else :
706700 agent_versions_to_build = gather_latest_agent_versions (release )
707701
708- logger .info (f"Building Agent versions: { agent_versions_to_build } for Operator versions: { operator_version } " )
702+ logger .info (f"Building Agent versions: { agent_versions_to_build } for Operator versions: { build_configuration . version } " )
709703
710704 tasks_queue = Queue ()
711705 max_workers = 1
@@ -728,7 +722,7 @@ def build_agent_default_case(build_configuration: BuildConfiguration):
728722 # )
729723 # )
730724 _build_agent_operator (
731- agent_version , build_configuration , executor , operator_version , tasks_queue , is_release
725+ agent_version , build_configuration , executor , build_configuration . version , tasks_queue , build_configuration . scenario == BuildScenario . RELEASE
732726 )
733727
734728 queue_exception_handling (tasks_queue )
@@ -834,12 +828,7 @@ def _build_agent_operator(
834828 f"https://downloads.mongodb.org/tools/db/mongodb-database-tools-{ tools_distro } -{ tools_version } .tgz"
835829 )
836830 mongodb_agent_url_ubi = f"https://mciuploads.s3.amazonaws.com/mms-automation/mongodb-mms-build-agent/builds/automation-agent/prod/mongodb-mms-automation-agent-{ agent_version [0 ]} .{ agent_distro } .tar.gz"
837- # We use Quay if not in a patch
838- # We could rely on input params (quay_registry or registry), but it makes templating more complex in the inventory
839- non_quay_registry = os .environ .get ("REGISTRY" , "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev" )
840- base_init_database_repo = QUAY_REGISTRY_URL if use_quay else non_quay_registry
841- TEMP_HARDCODED_BASE_REGISTRY = "268558157000.dkr.ecr.us-east-1.amazonaws.com/julienben/staging-temp"
842- init_database_image = f"{ TEMP_HARDCODED_BASE_REGISTRY } /mongodb-kubernetes-init-database:{ operator_version } "
831+ init_database_image = f"{ build_configuration .base_registry } /mongodb-kubernetes-init-database:{ operator_version } "
843832
844833 tasks_queue .put (
845834 executor .submit (
@@ -950,7 +939,7 @@ def build_init_database(build_configuration: BuildConfiguration):
950939 base_url = "https://fastdl.mongodb.org/tools/db/"
951940 mongodb_tools_url_ubi = "{}{}" .format (base_url , release ["mongodbToolsBundle" ]["ubi" ])
952941 version = build_configuration .version # TODO: check how to properly retrieve version
953- args = {"version" : version , "mongodb_tools_url_ubi" : mongodb_tools_url_ubi , "is_appdb" : False }
942+ args = {"version" : version , "mongodb_tools_url_ubi" : mongodb_tools_url_ubi }
954943 build_image_generic (
955944 "mongodb-kubernetes-init-database" ,
956945 "docker/mongodb-kubernetes-init-database/Dockerfile" ,
0 commit comments