diff --git a/src/compose/cfg/factory.py b/src/compose/cfg/factory.py index 59d9384..2358042 100644 --- a/src/compose/cfg/factory.py +++ b/src/compose/cfg/factory.py @@ -26,5 +26,5 @@ def cfg_data_factory(src_paths: SrcPaths) -> CfgData: src_paths.cfg_dir.name, frozenset(src_path_get_services(src_paths, data)), vols if vols else None, - frozenset(cfg_get_orgs(data, src_paths.cfg_file)), + frozenset(cfg_get_orgs(data)), ) diff --git a/src/compose/cfg/get.py b/src/compose/cfg/get.py index c823b62..58e9b77 100644 --- a/src/compose/cfg/get.py +++ b/src/compose/cfg/get.py @@ -1,5 +1,4 @@ from collections.abc import Iterator -from pathlib import Path from typing import cast from compose.cfg.entity import CfgData, CfgDataYaml, OrgData @@ -9,29 +8,12 @@ from compose.service.factory import services_yaml_factory from compose.util import read_yml -def cfg_get_orgs(data: CfgDataYaml, path: Path) -> Iterator[OrgData]: - # orgs = data.get("orgs") - # if orgs is None: - # yield OrgData( - # org_data.get("org"), - # org_data.get("url"), - # ) - orgs = "orgs" - try: - orgs = data[orgs] - except KeyError as e: - print(f'key "{orgs}" not in "{path!s}"') - raise KeyError(e) - org = "org" - for org_data in orgs: - try: - yield OrgData( - org_data[org], - org_data.get("url"), - ) - except KeyError as e: - print(f'key "{orgs}.{org}" not in "{path!s}"') - raise KeyError(e) +def cfg_get_orgs(data: CfgDataYaml) -> Iterator[OrgData]: + for org_data in data["orgs"]: + yield OrgData( + org_data["org"], + org_data.get("url"), + ) def cfg_get_services(cfg_data: CfgData) -> Iterator[tuple[str, Service]]: diff --git a/src/compose/service/factory.py b/src/compose/service/factory.py index 8f72611..78d1dd6 100644 --- a/src/compose/service/factory.py +++ b/src/compose/service/factory.py @@ -7,6 +7,5 @@ from compose.util import read_yml, validate_typed_dict def services_yaml_factory(path: Path): data = cast(ServiceYaml, read_yml(path)) - # data = read_yml(path) - validate_typed_dict(ServiceYaml, data) + validate_typed_dict(ServiceYaml, data, path) return data diff --git a/src/compose/util.py b/src/compose/util.py index 8a6bc20..0bd9c85 100644 --- a/src/compose/util.py +++ b/src/compose/util.py @@ -1,7 +1,7 @@ import re -from collections.abc import Mapping +from collections.abc import KeysView, Mapping from pathlib import Path -from typing import Any, ClassVar, KeysView, Protocol, cast, override +from typing import Any, ClassVar, Protocol, cast, override import yaml