Skip to content

Commit f3b4a43

Browse files
committed
Ensure platform_variant is set for S3 artifact uploads
Fixes: #303 Signed-off-by: Tobias Wolf <wolf@b1-systems.de> On-behalf-of: SAP <tobias.wolf@sap.com>
1 parent ca8aaa9 commit f3b4a43

File tree

7 files changed

+45
-16
lines changed

7 files changed

+45
-16
lines changed

.github/actions/features_parse/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ outputs:
1111
runs:
1212
using: composite
1313
steps:
14-
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.10.9
14+
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.10.10
1515
- id: result
1616
shell: bash
1717
run: |

.github/actions/flavors_parse/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ outputs:
1313
runs:
1414
using: composite
1515
steps:
16-
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.10.9
16+
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.10.10
1717
- id: matrix
1818
shell: bash
1919
run: |

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Installs the given GardenLinux Python library
44
inputs:
55
version:
66
description: GardenLinux Python library version
7-
default: "0.10.9"
7+
default: "0.10.10"
88
python_version:
99
description: Python version to setup
1010
default: "3.13"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "gardenlinux"
3-
version = "0.10.9"
3+
version = "0.10.10"
44
description = "Contains tools to work with the features directory of gardenlinux, for example deducting dependencies from feature sets or validating cnames"
55
authors = ["Garden Linux Maintainers <contact@gardenlinux.io>"]
66
license = "Apache-2.0"

src/gardenlinux/features/cname.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ def __init__(
5757
self._commit_id = None
5858
self._feature_elements_cached: Optional[List[str]] = None
5959
self._feature_flags_cached: Optional[List[str]] = None
60-
self._feature_platform_cached: Optional[str] = None
60+
self._feature_platforms_cached: Optional[str] = None
6161
self._feature_set_cached: Optional[str] = None
6262
self._platform_variant_cached: Optional[str] = None
63+
self._flavor = ""
64+
self._version = None
65+
6366
self._flag_multiple_platforms = bool(
6467
environ.get("GL_ALLOW_FRANKENSTEIN", False)
6568
)
66-
self._flavor = ""
67-
self._version = None
6869

6970
commit_id_or_hash = None
7071

src/gardenlinux/s3/s3_artifacts.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ def upload_from_directory(
182182
"paths": [],
183183
}
184184

185+
platform_variant = cname_object.platform_variant
186+
187+
if platform_variant is not None:
188+
metadata["platform_variant"] = platform_variant
189+
185190
re_object = re.compile("[^a-zA-Z0-9\\s+\\-=.\\_:/@]")
186191

187192
for artifact in artifacts_dir.iterdir():

tests/s3/test_s3_artifacts.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
from .conftest import S3Env
1212

1313
RELEASE_DATA = """
14-
GARDENLINUX_CNAME="container-amd64-1234.1-abc123"
15-
GARDENLINUX_VERSION=1234.1
16-
GARDENLINUX_COMMIT_ID="abc123"
17-
GARDENLINUX_COMMIT_ID_LONG="abc123long"
18-
GARDENLINUX_FEATURES="_usi,_trustedboot"
19-
GARDENLINUX_FEATURES_ELEMENTS=
20-
GARDENLINUX_FEATURES_FLAGS="_usi,_trustedboot"
21-
GARDENLINUX_FEATURES_PLATFORMS="container"
22-
"""
14+
GARDENLINUX_CNAME="container-amd64-1234.1-abc123"
15+
GARDENLINUX_VERSION=1234.1
16+
GARDENLINUX_COMMIT_ID="abc123"
17+
GARDENLINUX_COMMIT_ID_LONG="abc123long"
18+
GARDENLINUX_FEATURES="_usi,_trustedboot"
19+
GARDENLINUX_FEATURES_ELEMENTS=
20+
GARDENLINUX_FEATURES_FLAGS="_usi,_trustedboot"
21+
GARDENLINUX_FEATURES_PLATFORMS="container"
22+
"""
2323

2424

2525
def test_s3artifacts_init_success(s3_setup: S3Env) -> None:
@@ -240,6 +240,29 @@ def test_upload_from_directory_commit_mismatch_raises(s3_setup: S3Env) -> None:
240240
artifacts.upload_from_directory(env.cname, env.tmp_path)
241241

242242

243+
def test_upload_from_directory_with_platform_variant(s3_setup: S3Env) -> None:
244+
"""
245+
RuntimeError if version in release file does not match cname.
246+
"""
247+
# Arrange
248+
env = s3_setup
249+
release_path = env.tmp_path / f"{env.cname}.release"
250+
251+
release_path.write_text(RELEASE_DATA.strip() + "\nGARDENLINUX_PLATFORM_VARIANT=test")
252+
253+
# Act
254+
artifacts = S3Artifacts(env.bucket_name)
255+
artifacts.upload_from_directory(env.cname, env.tmp_path)
256+
257+
# Assert
258+
bucket = env.s3.Bucket(env.bucket_name)
259+
meta_obj = next(
260+
o for o in bucket.objects.all() if o.key == f"meta/singles/{env.cname}"
261+
)
262+
metadata = yaml.safe_load(meta_obj.get()["Body"].read())
263+
assert metadata["platform_variant"] == "test"
264+
265+
243266
def test_upload_directory_with_requirements_override(s3_setup: S3Env) -> None:
244267
"""Ensure .requirements file values overide feature flag defaults."""
245268
# Arrange

0 commit comments

Comments
 (0)