utils.domains package

Submodules

utils.domains.application_domain_index module

utils.domains.application_domain_index.build_domain_index(applications: dict[str, Any], include_aliases: bool = True) → dict[str, str]

Build a case-insensitive domain -> application_id index. If the same domain appears in multiple apps (case-insensitive), raises an error.

Cached keyed on (applications fingerprint, include_aliases); the result is returned as-is, so callers MUST treat it as read-only.

utils.domains.application_domain_index.iter_app_domains(app_conf: Any, include_aliases: bool = True) → Iterable[str]

Yield all canonical + alias domains from an app config.

Expected structure:

applications[app_id].domains.canonical applications[app_id].domains.aliases

utils.domains.application_domain_index.resolve_app_id_for_domain(applications: dict[str, Any], domain: str) → str | None

Resolve application_id for a given domain (canonical or alias) by scanning applications[*].domains.

Returns None if not found.

utils.domains.default_primary module

The CI/dev primary domain, read from default.env (the SPOT).

utils.domains.default_primary.default_domain_primary() → str

The INFINITO_DOMAIN fallback declared in default.env.

Consumers that take an explicit domain or read one from the environment fall back here rather than repeating the literal, so changing the CI/dev default is a one-line edit in default.env instead of a hunt through the tree.

utils.domains.list module

utils.domains.list.add_www_variants(domains: list[str]) → list[str]
utils.domains.list.build_applications_from_roles(roles_dir: Path, domain_primary: str) → dict[str, dict[str, Any]]
utils.domains.list.list_application_domains(domain_primary: str, *, include_aliases: bool = False, include_www: bool = False) → list[str]
utils.domains.list.list_derived_domains(domain_primary: str) → list[str]
utils.domains.list.load_yaml_mapping(path: Path) → dict[str, Any]
utils.domains.list.render_domain_value(value: Any, variables: dict[str, Any], field_name: str) → Any

utils.domains.primary_domain module

utils.domains.primary_domain.get_domain(domains, application_id)
utils.domains.primary_domain.get_primary_domain(domains, application_id)
Return the primary domain for application_id from the domains mapping:
  • If value is a string, return it.

  • If value is a dict, return its first value.

  • If value is a list, return its first element.

  • Otherwise, raise an error.

utils.domains.unserved module

utils.domains.unserved.served_domains(domains: Any, services: Any) → list[str]

Return the domains of one application that it serves itself.

Parameters:
  • domains – the application’s entry of the resolved domains map, a list, or a mapping of canonical key to domain where onion mirrors sit under <key>_onion.

  • services – the application’s services mapping.

Returns:

The domain values without those of the keys unserved_canonical_keys names and without their onion mirrors.

utils.domains.unserved.unserved_canonical_keys(services: Any) → set[str]

Return the canonical domain keys an application does not serve.

Parameters:

services – the application’s services mapping. An entity that lists domains claims those canonical keys.

Returns:

The keys of every claiming entity that is disabled, or enabled but shared, because its provider serves that surface instead.

Module contents

Shared domain helpers for Infinito.Nexus.