Skip to content

Commit b140220

Browse files
committed
Move all env vars to constants.py
1 parent f894e5b commit b140220

File tree

5 files changed

+28
-45
lines changed

5 files changed

+28
-45
lines changed

docker/mongodb-community-tests/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
#
77
# Ref: https://cryptography.io/en/latest/installation/#building-cryptography-on-linux
88
#
9-
ARG GOLANG_VERSION
10-
11-
FROM public.ecr.aws/docker/library/golang:${GOLANG_VERSION} as builder
9+
FROM public.ecr.aws/docker/library/golang:1.24 as builder
1210

1311
ENV GO111MODULE=on
1412
ENV GOPATH ""

scripts/release/atomic_pipeline.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,19 @@ def build_mco_tests_image(build_configuration: ImageBuildConfiguration):
122122
"""
123123
Builds image used to run community tests.
124124
"""
125-
golang_version = os.getenv("GOLANG_VERSION", "1.24")
126-
if golang_version == "":
127-
raise Exception("Missing GOLANG_VERSION environment variable")
128-
129-
buildargs = dict({"GOLANG_VERSION": golang_version})
130125

131126
pipeline_process_image(
132127
dockerfile_path="docker/mongodb-community-tests/Dockerfile",
133128
build_configuration=build_configuration,
134-
dockerfile_args=buildargs,
135129
)
136130

137131

138132
def build_operator_image(build_configuration: ImageBuildConfiguration):
139133
"""Calculates arguments required to build the operator image, and starts the build process."""
140134
# In evergreen, we can pass test_suffix env to publish the operator to a quay
141135
# repository with a given suffix.
142-
test_suffix = os.environ.get("test_suffix", "")
143-
log_automation_config_diff = os.environ.get("LOG_AUTOMATION_CONFIG_DIFF", "false")
136+
test_suffix = os.getenv("test_suffix", "")
137+
log_automation_config_diff = os.getenv("LOG_AUTOMATION_CONFIG_DIFF", "false")
144138

145139
args = {
146140
"version": build_configuration.version,
@@ -283,17 +277,9 @@ def build_readiness_probe_image(build_configuration: ImageBuildConfiguration):
283277
Builds image used for readiness probe.
284278
"""
285279

286-
golang_version = os.getenv("GOLANG_VERSION", "1.24")
287-
288-
extra_args = {
289-
"version": build_configuration.version,
290-
"GOLANG_VERSION": golang_version,
291-
}
292-
293280
pipeline_process_image(
294281
dockerfile_path="docker/mongodb-kubernetes-readinessprobe/Dockerfile",
295282
build_configuration=build_configuration,
296-
dockerfile_args=extra_args,
297283
)
298284

299285

@@ -302,17 +288,9 @@ def build_upgrade_hook_image(build_configuration: ImageBuildConfiguration):
302288
Builds image used for version upgrade post-start hook.
303289
"""
304290

305-
golang_version = os.getenv("GOLANG_VERSION", "1.24")
306-
307-
extra_args = {
308-
"version": build_configuration.version,
309-
"GOLANG_VERSION": golang_version,
310-
}
311-
312291
pipeline_process_image(
313292
dockerfile_path="docker/mongodb-kubernetes-upgrade-hook/Dockerfile",
314293
build_configuration=build_configuration,
315-
dockerfile_args=extra_args,
316294
)
317295

318296

scripts/release/build/build_scenario.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from git import Repo
66

77
from scripts.release.version import calculate_next_version
8+
from scripts.release.constants import triggered_by_git_tag, is_evg_patch, is_running_in_evg, get_version_id
89

910
COMMIT_SHA_LENGTH = 8
1011

@@ -18,10 +19,10 @@ class BuildScenario(StrEnum):
1819
@classmethod
1920
def infer_scenario_from_environment(cls) -> "BuildScenario":
2021
"""Infer the build scenario from environment variables."""
21-
git_tag = os.getenv("triggered_by_git_tag")
22-
is_patch = os.getenv("is_patch", "false").lower() == "true"
23-
is_evg = os.getenv("RUNNING_IN_EVG", "false").lower() == "true"
24-
patch_id = os.getenv("version_id")
22+
git_tag = triggered_by_git_tag()
23+
is_patch = is_evg_patch()
24+
is_evg = is_running_in_evg()
25+
patch_id = get_version_id()
2526

2627
if git_tag:
2728
# Release scenario and the git tag will be used for promotion process only
@@ -46,7 +47,7 @@ def get_version(self, repository_path: str, changelog_sub_path: str, initial_com
4647

4748
match self:
4849
case BuildScenario.PATCH:
49-
patch_id = os.getenv("version_id")
50+
patch_id = get_version_id()
5051
if not patch_id:
5152
raise ValueError(f"version_id environment variable is not set for `{self}` build scenario")
5253
return patch_id

scripts/release/constants.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,19 @@ def get_initial_version() -> str | None:
1414

1515
def get_initial_commit_sha() -> str | None:
1616
return os.getenv(RELEASE_INITIAL_COMMIT_SHA_ENV_VAR)
17+
18+
19+
def triggered_by_git_tag() -> str | None:
20+
return os.getenv("triggered_by_git_tag")
21+
22+
23+
def is_evg_patch() -> bool:
24+
return os.getenv("is_patch", "false").lower() == "true"
25+
26+
27+
def is_running_in_evg() -> bool:
28+
return os.getenv("RUNNING_IN_EVG", "false").lower() == "true"
29+
30+
31+
def get_version_id() -> str | None:
32+
return os.getenv("version_id")

scripts/release/pipeline_main.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ def get_builder_function_for_image_name() -> Dict[str, Callable]:
5656
"upgrade-hook": build_upgrade_hook_image, # working, but still using single arch build
5757
"operator-quick": build_operator_image_patch, # TODO: remove this image, it is not used anymore
5858
"database": build_database_image, # working
59-
"agent-pct": build_agent_on_agent_bump,
60-
"agent": build_agent_default_case,
59+
"agent": build_agent_default_case, # working
6160
# Init images
6261
"init-appdb": build_init_appdb_image, # working
6362
"init-database": build_init_database_image, # working
6463
"init-ops-manager": build_init_om_image, # working
6564
# Ops Manager image
66-
"ops-manager": build_om_image,
65+
"ops-manager": build_om_image, # working
6766
}
6867

6968
return image_builders
@@ -185,16 +184,7 @@ def main():
185184
"--registry",
186185
help="Override the base registry instead of resolving from build scenario",
187186
)
188-
parser.add_argument(
189-
"--sign", action="store_true", help="Force signing instead of resolving condition from build scenario"
190-
)
191-
192-
# Agent specific arguments
193-
parser.add_argument(
194-
"--all-agents",
195-
action="store_true",
196-
help="Build all agent variants instead of only the latest",
197-
)
187+
# For agent builds
198188
parser.add_argument(
199189
"--parallel-factor",
200190
default=0,

0 commit comments

Comments
 (0)