diff --git a/oci/src/proxmenux_oci/custom.py b/oci/src/proxmenux_oci/custom.py index 1e42c719..51923334 100644 --- a/oci/src/proxmenux_oci/custom.py +++ b/oci/src/proxmenux_oci/custom.py @@ -174,7 +174,7 @@ def template_from_compose(text: str, title: str | None = None) -> dict[str, Any] def _template_from_stack(compose: dict[str, Any], title: str | None) -> dict[str, Any]: """Reuse the catalog stack compiler, keeping explicitly selected image versions.""" - from .stack import apply_stack_support + from .stack import apply_stack_support, normalized_mounts services = _services(compose) singles = {} @@ -210,9 +210,8 @@ def _template_from_stack(compose: dict[str, Any], title: str | None) -> dict[str if 'environment' in services[service['name']]: service['compose']['environment'] = copy.deepcopy(services[service['name']]['environment']) service['compose']['volumes'] = [ - mount for mount in service['compose'].get('volumes', []) - if (mount.get('target') if isinstance(mount, dict) - else str(mount).split(':')[-1]) not in TIME_SETTINGS] + mount for mount in normalized_mounts(service['compose'].get('volumes', [])) + if mount['target'] not in TIME_SETTINGS] template['container_contract']['original_compose'] = _dump({ **template['compose_stack']['top_level'], 'services': {service['name']: service['compose'] for service in template['compose_stack']['services']}}) diff --git a/oci/tests/test_custom_compose_stacks.py b/oci/tests/test_custom_compose_stacks.py index 18ca3888..142ffea4 100644 --- a/oci/tests/test_custom_compose_stacks.py +++ b/oci/tests/test_custom_compose_stacks.py @@ -55,6 +55,14 @@ class CustomComposeStacks(unittest.TestCase): with self.subTest(metadata=metadata), self.assertRaises(ConversionError): custom.template_from_compose(COMPOSE + metadata + '\n') + def test_short_read_only_time_mount_is_removed_from_stack(self): + text = COMPOSE.replace(" ports:", " volumes: [/etc/localtime:/etc/localtime:ro]\n ports:") + template = custom.template_from_compose(text) + app = next(service for service in ordered_services(template) if service['name'] == 'app') + self.assertEqual(app['compose']['volumes'], []) + self.assertFalse(any('System path' in error for error in template['compatibility']['untranslated_blockers'])) + self.assertTrue(template['compatibility']['automatic_install_candidate']) + def test_written_digest_and_tag_survive_in_full_image_contracts(self): digest = 'sha256:' + 'a' * 64 reference = 'ghcr.io/example/adminer:4@' + digest