Skip to content

Commit 8183ec5

Browse files
committed
Fix release_info.py structure
1 parent c5ad3c5 commit 8183ec5

File tree

3 files changed

+92
-31
lines changed

3 files changed

+92
-31
lines changed

scripts/release/build/build_info.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
from scripts.release.constants import DEFAULT_REPOSITORY_PATH, DEFAULT_CHANGELOG_PATH, RELEASE_INITIAL_VERSION_ENV_VAR, \
77
get_initial_version, get_initial_commit_sha
88

9+
MEKO_TESTS_IMAGE = "meko-tests"
10+
OPERATOR_IMAGE = "operator"
11+
MCO_TESTS_IMAGE = "mco-tests"
12+
READINESS_PROBE_IMAGE = "readiness-probe"
13+
UPGRADE_HOOK_IMAGE = "upgrade-hook"
14+
DATABASE_IMAGE = "database"
15+
AGENT_IMAGE = "agent"
16+
INIT_APPDB_IMAGE = "init-appdb"
17+
INIT_DATABASE_IMAGE = "init-database"
18+
INIT_OPS_MANAGER_IMAGE = "init-ops-manager"
19+
OPS_MANAGER_IMAGE = "ops-manager"
20+
921

1022
@dataclass
1123
class ImageInfo:
@@ -14,9 +26,6 @@ class ImageInfo:
1426
version: str
1527
sign: bool
1628

17-
def to_release_info_json(self):
18-
return {"repository": self.repository, "platforms": self.platforms, "version": self.version}
19-
2029

2130
@dataclass
2231
class BinaryInfo:
@@ -25,34 +34,20 @@ class BinaryInfo:
2534
version: str
2635
sign: bool
2736

28-
def to_release_info_json(self):
29-
return {"platforms": self.platforms, "version": self.version}
30-
3137

3238
@dataclass
3339
class HelmChartInfo:
3440
repository: str
3541
version: str
3642
sign: bool
3743

38-
def to_release_info_json(self):
39-
return {"repository": self.repository, "version": self.version}
40-
4144

4245
@dataclass
4346
class BuildInfo:
4447
images: Dict[str, ImageInfo]
4548
binaries: Dict[str, BinaryInfo]
4649
helm_charts: Dict[str, HelmChartInfo]
4750

48-
def to_release_info_json(self):
49-
return {
50-
"images": {name: images.to_release_info_json() for name, images in self.images.items() if
51-
name not in ["agent", "ops-manager"]},
52-
"binaries": {name: bin.to_release_info_json() for name, bin in self.binaries.items()},
53-
"helm-charts": {name: chart.to_release_info_json() for name, chart in self.helm_charts.items()},
54-
}
55-
5651

5752
def load_build_info(scenario: BuildScenario,
5853
repository_path: str = DEFAULT_REPOSITORY_PATH,

scripts/release/pipeline_main.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,20 @@
2828
build_tests_image,
2929
build_upgrade_hook_image,
3030
)
31-
from scripts.release.build.build_info import load_build_info
31+
from scripts.release.build.build_info import (
32+
AGENT_IMAGE,
33+
DATABASE_IMAGE,
34+
INIT_APPDB_IMAGE,
35+
INIT_DATABASE_IMAGE,
36+
INIT_OPS_MANAGER_IMAGE,
37+
MCO_TESTS_IMAGE,
38+
MEKO_TESTS_IMAGE,
39+
OPERATOR_IMAGE,
40+
OPS_MANAGER_IMAGE,
41+
READINESS_PROBE_IMAGE,
42+
UPGRADE_HOOK_IMAGE,
43+
load_build_info,
44+
)
3245
from scripts.release.build.build_scenario import (
3346
BuildScenario,
3447
)
@@ -48,19 +61,19 @@ def get_builder_function_for_image_name() -> Dict[str, Callable]:
4861
"""Returns a dictionary of image names that can be built."""
4962

5063
image_builders = {
51-
"meko-tests": build_tests_image, # working
52-
"operator": build_operator_image, # working
53-
"mco-tests": build_mco_tests_image, # working
54-
"readiness-probe": build_readiness_probe_image, # working
55-
"upgrade-hook": build_upgrade_hook_image, # working
56-
"database": build_database_image, # working
57-
"agent": build_agent_default_case, # working
64+
MEKO_TESTS_IMAGE: build_tests_image, # working
65+
OPERATOR_IMAGE: build_operator_image, # working
66+
MCO_TESTS_IMAGE: build_mco_tests_image, # working
67+
READINESS_PROBE_IMAGE: build_readiness_probe_image, # working
68+
UPGRADE_HOOK_IMAGE: build_upgrade_hook_image, # working
69+
DATABASE_IMAGE: build_database_image, # working
70+
AGENT_IMAGE: build_agent_default_case, # working
5871
# Init images
59-
"init-appdb": build_init_appdb_image, # working
60-
"init-database": build_init_database_image, # working
61-
"init-ops-manager": build_init_om_image, # working
72+
INIT_APPDB_IMAGE: build_init_appdb_image, # working
73+
INIT_DATABASE_IMAGE: build_init_database_image, # working
74+
INIT_OPS_MANAGER_IMAGE: build_init_om_image, # working
6275
# Ops Manager image
63-
"ops-manager": build_om_image, # working
76+
OPS_MANAGER_IMAGE: build_om_image, # working
6477
}
6578

6679
return image_builders

scripts/release/release_info.py

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,34 @@
22
import json
33
import pathlib
44

5-
from scripts.release.build.build_info import load_build_info
5+
from scripts.release.build.build_info import (
6+
DATABASE_IMAGE,
7+
INIT_APPDB_IMAGE,
8+
INIT_DATABASE_IMAGE,
9+
INIT_OPS_MANAGER_IMAGE,
10+
OPERATOR_IMAGE,
11+
READINESS_PROBE_IMAGE,
12+
UPGRADE_HOOK_IMAGE,
13+
BuildInfo,
14+
load_build_info,
15+
)
616
from scripts.release.build.build_scenario import BuildScenario
717
from scripts.release.constants import (
818
DEFAULT_CHANGELOG_PATH,
919
DEFAULT_RELEASE_INITIAL_VERSION,
1020
DEFAULT_REPOSITORY_PATH,
1121
)
1222

23+
RELEASE_INFO_IMAGES_ORDERED = [
24+
OPERATOR_IMAGE,
25+
INIT_DATABASE_IMAGE,
26+
INIT_APPDB_IMAGE,
27+
INIT_OPS_MANAGER_IMAGE,
28+
DATABASE_IMAGE,
29+
READINESS_PROBE_IMAGE,
30+
UPGRADE_HOOK_IMAGE,
31+
]
32+
1333

1434
def create_release_info_json(
1535
repository_path: str, changelog_sub_path: str, initial_commit_sha: str = None, initial_version: str = None
@@ -22,7 +42,40 @@ def create_release_info_json(
2242
initial_version=initial_version,
2343
)
2444

25-
return json.dumps(build_info.to_release_info_json(), indent=2)
45+
release_info_json = convert_to_release_info_json(build_info)
46+
47+
return json.dumps(release_info_json, indent=2)
48+
49+
50+
def convert_to_release_info_json(build_info: BuildInfo) -> dict:
51+
output = {
52+
"images": {},
53+
"binaries": {},
54+
"helm-charts": {},
55+
}
56+
# Filter (and order) images to include only those relevant for release info
57+
images = {name: build_info.images[name] for name in RELEASE_INFO_IMAGES_ORDERED}
58+
59+
for name, image in images.items():
60+
output["images"][name] = {
61+
"repository": image.repository,
62+
"platforms": image.platforms,
63+
"version": image.version,
64+
}
65+
66+
for name, binary in build_info.binaries.items():
67+
output["binaries"][name] = {
68+
"platforms": binary.platforms,
69+
"version": binary.version,
70+
}
71+
72+
for name, chart in build_info.helm_charts.items():
73+
output["helm-charts"][name] = {
74+
"repository": chart.repository,
75+
"version": chart.version,
76+
}
77+
78+
return output
2679

2780

2881
if __name__ == "__main__":

0 commit comments

Comments
 (0)