diff --git a/.github/actions/features_parse/action.yml b/.github/actions/features_parse/action.yml index 274a00b5..dac7b586 100644 --- a/.github/actions/features_parse/action.yml +++ b/.github/actions/features_parse/action.yml @@ -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: | diff --git a/.github/actions/flavors_parse/action.yml b/.github/actions/flavors_parse/action.yml index 28cd6081..9bb8ff79 100644 --- a/.github/actions/flavors_parse/action.yml +++ b/.github/actions/flavors_parse/action.yml @@ -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: | diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 491a0f26..7021f953 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -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" diff --git a/pyproject.toml b/pyproject.toml index aa9e8d37..9a17b7ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "Apache-2.0" diff --git a/src/gardenlinux/features/cname.py b/src/gardenlinux/features/cname.py index 3822d793..a1e2554c 100644 --- a/src/gardenlinux/features/cname.py +++ b/src/gardenlinux/features/cname.py @@ -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 diff --git a/src/gardenlinux/s3/s3_artifacts.py b/src/gardenlinux/s3/s3_artifacts.py index 8bf686f6..25bb030d 100644 --- a/src/gardenlinux/s3/s3_artifacts.py +++ b/src/gardenlinux/s3/s3_artifacts.py @@ -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(): diff --git a/tests/s3/test_s3_artifacts.py b/tests/s3/test_s3_artifacts.py index 8b7e4016..3c48d282 100644 --- a/tests/s3/test_s3_artifacts.py +++ b/tests/s3/test_s3_artifacts.py @@ -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: @@ -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