Skip to content

Commit 1e389af

Browse files
committed
Differentiate platform and platforms in the GardenLinux canonical name
Signed-off-by: Tobias Wolf <[email protected]> On-behalf-of: SAP <[email protected]>
1 parent 1239276 commit 1e389af

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

src/gardenlinux/features/cname.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, cname, arch=None, commit_hash=None, version=None):
5151
self._commit_id = None
5252
self._feature_elements_cached = None
5353
self._feature_flags_cached = None
54-
self._feature_platform_cached = None
54+
self._feature_platforms_cached = None
5555
self._feature_set_cached = None
5656
self._platform_variant_cached = None
5757

@@ -239,10 +239,10 @@ def feature_set_platform(self) -> str:
239239
:since: 1.0.0
240240
"""
241241

242-
if self._feature_platform_cached is not None:
243-
return self._feature_platform_cached
244-
245-
platforms = Parser().filter_as_dict(self.flavor)["platform"]
242+
if self._feature_platforms_cached is None:
243+
platforms = Parser().filter_as_dict(self.flavor)["platform"]
244+
else:
245+
platforms = self._feature_platforms_cached
246246

247247
if self._flag_multiple_platforms:
248248
return ",".join(platforms)
@@ -260,7 +260,15 @@ def platform(self) -> str:
260260
:since: 0.7.0
261261
"""
262262

263-
return self.feature_set_platform
263+
if self._feature_platforms_cached is None:
264+
platforms = Parser().filter_as_dict(self.flavor)["platform"]
265+
else:
266+
platforms = self._feature_platforms_cached
267+
268+
if not self._flag_multiple_platforms:
269+
assert len(platforms) < 2
270+
271+
return platforms[0]
264272

265273
@property
266274
def platform_variant(self) -> Optional[str]:
@@ -306,8 +314,9 @@ def release_metadata_string(self) -> str:
306314

307315
elements = ",".join(features["element"])
308316
flags = ",".join(features["flag"])
309-
platform = ",".join(features["platform"])
317+
platform = features["platform"][0]
310318
platform_variant = self.platform_variant
319+
platforms = ",".join(features["platform"])
311320

312321
if platform_variant is None:
313322
platform_variant = ""
@@ -323,9 +332,10 @@ def release_metadata_string(self) -> str:
323332
BUG_REPORT_URL="{GL_BUG_REPORT_URL}"
324333
GARDENLINUX_CNAME="{self.cname}"
325334
GARDENLINUX_FEATURES="{self.feature_set}"
326-
GARDENLINUX_FEATURES_PLATFORM="{platform}"
335+
GARDENLINUX_FEATURES_PLATFORMS="{platforms}"
327336
GARDENLINUX_FEATURES_ELEMENTS="{elements}"
328337
GARDENLINUX_FEATURES_FLAGS="{flags}"
338+
GARDENLINUX_PLATFORM="{platform}"
329339
GARDENLINUX_PLATFORM_VARIANT="{platform_variant}"
330340
GARDENLINUX_VERSION="{self.version}"
331341
GARDENLINUX_COMMIT_ID="{self.commit_id}"
@@ -384,7 +394,7 @@ def load_from_release_file(self, release_file: PathLike | str) -> None:
384394
"GARDENLINUX_FEATURES",
385395
"GARDENLINUX_FEATURES_ELEMENTS",
386396
"GARDENLINUX_FEATURES_FLAGS",
387-
"GARDENLINUX_FEATURES_PLATFORM",
397+
"GARDENLINUX_FEATURES_PLATFORMS",
388398
"GARDENLINUX_VERSION",
389399
):
390400
if not release_config.has_option(UNNAMED_SECTION, release_field):
@@ -439,9 +449,11 @@ def load_from_release_file(self, release_file: PathLike | str) -> None:
439449
.split(",")
440450
)
441451

442-
self._feature_platform_cached = release_config.get(
443-
UNNAMED_SECTION, "GARDENLINUX_FEATURES_PLATFORM"
444-
).strip("\"'")
452+
self._feature_platforms_cached = (
453+
release_config.get(UNNAMED_SECTION, "GARDENLINUX_FEATURES_PLATFORMS")
454+
.strip("\"'")
455+
.split(",")
456+
)
445457

446458
if release_config.has_option(UNNAMED_SECTION, "GARDENLINUX_PLATFORM_VARIANT"):
447459
self._platform_variant_cached = release_config.get(

tests/features/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ def generate_container_amd64_release_metadata(version, commit_hash):
1919
BUG_REPORT_URL="{GL_BUG_REPORT_URL}"
2020
GARDENLINUX_CNAME="container-amd64-{version}-{commit_hash}"
2121
GARDENLINUX_FEATURES="_slim,base,container"
22-
GARDENLINUX_FEATURES_PLATFORM="container"
22+
GARDENLINUX_FEATURES_PLATFORMS="container"
2323
GARDENLINUX_FEATURES_ELEMENTS="base"
2424
GARDENLINUX_FEATURES_FLAGS="_slim"
25+
GARDENLINUX_PLATFORM="container"
2526
GARDENLINUX_PLATFORM_VARIANT=""
2627
GARDENLINUX_VERSION="{version}"
2728
GARDENLINUX_COMMIT_ID="{commit_hash}"

0 commit comments

Comments
 (0)