Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/features_parse/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ outputs:
runs:
using: composite
steps:
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.10.9
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.10.10
- id: result
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/flavors_parse/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ outputs:
runs:
using: composite
steps:
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.10.9
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.10.10
- id: matrix
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Installs the given GardenLinux Python library
inputs:
version:
description: GardenLinux Python library version
default: "0.10.9"
default: "0.10.10"
python_version:
description: Python version to setup
default: "3.13"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gardenlinux"
version = "0.10.9"
version = "0.10.10"
description = "Contains tools to work with the features directory of gardenlinux, for example deducting dependencies from feature sets or validating cnames"
authors = ["Garden Linux Maintainers <contact@gardenlinux.io>"]
license = "Apache-2.0"
Expand Down
7 changes: 4 additions & 3 deletions src/gardenlinux/features/cname.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ def __init__(
self._commit_id = None
self._feature_elements_cached: Optional[List[str]] = None
self._feature_flags_cached: Optional[List[str]] = None
self._feature_platform_cached: Optional[str] = None
self._feature_platforms_cached: Optional[List[str]] = None
self._feature_set_cached: Optional[str] = None
self._platform_variant_cached: Optional[str] = None
self._flavor = ""
self._version = None

self._flag_multiple_platforms = bool(
environ.get("GL_ALLOW_FRANKENSTEIN", False)
)
self._flavor = ""
self._version = None

commit_id_or_hash = None

Expand Down
5 changes: 5 additions & 0 deletions src/gardenlinux/s3/s3_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ def upload_from_directory(
"paths": [],
}

platform_variant = cname_object.platform_variant

if platform_variant is not None:
metadata["platform_variant"] = platform_variant

re_object = re.compile("[^a-zA-Z0-9\\s+\\-=.\\_:/@]")

for artifact in artifacts_dir.iterdir():
Expand Down
43 changes: 34 additions & 9 deletions tests/s3/test_s3_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
from .conftest import S3Env

RELEASE_DATA = """
GARDENLINUX_CNAME="container-amd64-1234.1-abc123"
GARDENLINUX_VERSION=1234.1
GARDENLINUX_COMMIT_ID="abc123"
GARDENLINUX_COMMIT_ID_LONG="abc123long"
GARDENLINUX_FEATURES="_usi,_trustedboot"
GARDENLINUX_FEATURES_ELEMENTS=
GARDENLINUX_FEATURES_FLAGS="_usi,_trustedboot"
GARDENLINUX_FEATURES_PLATFORMS="container"
"""
GARDENLINUX_CNAME="container-amd64-1234.1-abc123"
GARDENLINUX_VERSION=1234.1
GARDENLINUX_COMMIT_ID="abc123"
GARDENLINUX_COMMIT_ID_LONG="abc123long"
GARDENLINUX_FEATURES="_usi,_trustedboot"
GARDENLINUX_FEATURES_ELEMENTS=
GARDENLINUX_FEATURES_FLAGS="_usi,_trustedboot"
GARDENLINUX_FEATURES_PLATFORMS="container"
"""


def test_s3artifacts_init_success(s3_setup: S3Env) -> None:
Expand Down Expand Up @@ -240,6 +240,31 @@ def test_upload_from_directory_commit_mismatch_raises(s3_setup: S3Env) -> None:
artifacts.upload_from_directory(env.cname, env.tmp_path)


def test_upload_from_directory_with_platform_variant(s3_setup: S3Env) -> None:
"""
RuntimeError if version in release file does not match cname.
"""
# Arrange
env = s3_setup
release_path = env.tmp_path / f"{env.cname}.release"

release_path.write_text(
RELEASE_DATA.strip() + "\nGARDENLINUX_PLATFORM_VARIANT=test"
)

# Act
artifacts = S3Artifacts(env.bucket_name)
artifacts.upload_from_directory(env.cname, env.tmp_path)

# Assert
bucket = env.s3.Bucket(env.bucket_name)
meta_obj = next(
o for o in bucket.objects.all() if o.key == f"meta/singles/{env.cname}"
)
metadata = yaml.safe_load(meta_obj.get()["Body"].read())
assert metadata["platform_variant"] == "test"


def test_upload_directory_with_requirements_override(s3_setup: S3Env) -> None:
"""Ensure .requirements file values overide feature flag defaults."""
# Arrange
Expand Down