app.catalog_config

Load and validate catalog.yaml: sources, approval policy and RBAC.

The file (ADRIANO_CONFIG_FILE) is read once at startup; changes need a restart. Validation never aborts the whole load:

  • An invalid sources entry becomes a disabled registration with a readable config_error; the other registrations keep working. An entry without a usable id (or with a duplicate one) cannot be stored and is only reported. Type-specific settings are validated by the source type registry (app.sources.registry), i.e. at the adapter boundary. See app.source_config.

  • A missing approval_policy yields PolicyStatus.MISSING, an invalid one PolicyStatus.INVALID, each with a message. Neither is ever treated as “approval not required”.

  • An invalid rbac section grants no permissions.

  • A missing or unparseable file yields an empty configuration with ConfigFileStatus.MISSING / ConfigFileStatus.INVALID.

Every finding is a ConfigProblem (check-config exits non-zero when one has error severity).

Secrets are referenced by environment variable name (for example push_tokens_env, GitLab token_env). Values are resolved from the injected environment mapping, held as pydantic.SecretStr, never logged, never part of messages and never stored in the registration config.

Public API: ConfigFileStatus, Permission, PolicyConfig, RbacConfig, CatalogConfig, load_catalog_config(), parse_catalog_config(), and re-exported from app.source_config: ConfigProblem, SourceRegistration.

class app.catalog_config.CatalogConfig(*, path, file_status, sources=(), policy=PolicyConfig(status=<PolicyStatus.MISSING: 'missing'>, policy=None, message=None), rbac=RbacConfig(roles={}), problems=())

Bases: object

The loaded configuration.

Parameters:
path: str
file_status: ConfigFileStatus
sources: tuple[SourceRegistration, ...]
policy: PolicyConfig
rbac: RbacConfig
problems: tuple[ConfigProblem, ...]
property has_errors: bool

Tell whether any problem has error severity.

Returns:

True if at least one error was found.

registration_configs()

Build the registration values to sync into storage.

Return type:

list[RegistrationConfig]

Returns:

One value per registration.

get_source(source_id)

Find a registration by id.

Parameters:

source_id (str) – Registration id.

Return type:

SourceRegistration | None

Returns:

The registration, or None.

class app.catalog_config.ConfigFileStatus(*values)

Bases: StrEnum

Whether the configuration file could be read and parsed.

OK = 'ok'
MISSING = 'missing'
INVALID = 'invalid'
class app.catalog_config.ConfigProblem(severity, location, message)

Bases: object

One configuration finding.

Parameters:
  • severity (Severity) – error (something is disabled) or warning.

  • location (str) – Where in the file, e.g. sources[1] (central).

  • message (str) – Readable, secret-free description.

severity: Severity
location: str
message: str
class app.catalog_config.Permission(*values)

Bases: StrEnum

Permissions an IdP role can grant (review comes from the policy).

READ = 'read'
OPERATE = 'operate'
class app.catalog_config.PolicyConfig(status, policy=None, message=None)

Bases: object

Status of the global approval policy.

Parameters:
  • status (PolicyStatus) – Configured, missing or invalid.

  • policy (Policy | None) – The policy when configured.

  • message (str | None) – Why it is missing or invalid.

status: PolicyStatus
policy: Policy | None
message: str | None
class app.catalog_config.RbacConfig(roles=dict())

Bases: object

IdP role -> permissions mapping.

Parameters:

roles (Mapping[str, frozenset[Permission]]) – Permissions granted per role name.

roles: Mapping[str, frozenset[Permission]]
permissions_for(roles)

Collect the permissions granted by a caller’s roles.

Parameters:

roles (Iterable[str]) – Role names from the verified token.

Return type:

frozenset[Permission]

Returns:

The union of granted permissions.

class app.catalog_config.SourceRegistration(*, id, type, position, config, enabled, config_error=None, config_error_code=None, path='doc/decisions', published_ref='', intake=frozenset({}), push_tokens=(), binding=None, warnings=())

Bases: object

One configured source registration.

Parameters:
  • id (str) – Stable registration id.

  • type (str) – Source type name.

  • position (int) – Index in the configuration (ownership order).

  • config (JsonObject) – Non-secret settings as stored in the database.

  • enabled (bool) – False when the entry is invalid.

  • config_error (str | None) – Why the entry is disabled.

  • config_error_code (ConfigErrorCode | None) – Stable code of config_error.

  • path (str) – ADR path inside each project.

  • published_ref (str) – Configured published ref.

  • intake (frozenset[IntakeKind]) – Enabled intake mechanisms.

  • push_tokens (tuple[SecretStr, ...]) – Resolved CI push tokens (never logged).

  • binding (SourceBinding | None) – Adapter factory; None when disabled.

  • warnings (tuple[str, ...]) – Non-fatal findings for this registration.

id: str
type: str
position: int
config: JsonObject
enabled: bool
config_error: str | None
config_error_code: ConfigErrorCode | None
path: str
published_ref: str
intake: frozenset[IntakeKind]
push_tokens: tuple[SecretStr, ...]
binding: SourceBinding | None
warnings: tuple[str, ...]
property pollable: bool

Tell whether polling may run for this registration.

Returns:

True if enabled with poll intake.

to_storage()

Convert to the value synced into source_registration.

Return type:

RegistrationConfig

Returns:

The registration config (no secrets).

app.catalog_config.load_catalog_config(path, *, env, registry)

Load and validate catalog.yaml. Never raises for bad content.

Parameters:
Return type:

CatalogConfig

Returns:

The configuration with all problems found.

app.catalog_config.parse_catalog_config(data, *, path, env, registry, base_dir)

Validate an already parsed configuration mapping.

Parameters:
  • data (Mapping[str, object]) – Top-level YAML mapping.

  • path (str) – Configuration file path (for reporting).

  • env (Mapping[str, str]) – Environment used to resolve secret env var names.

  • registry (SourceTypeRegistry) – Source type registry.

  • base_dir (Path) – Directory for relative paths in source settings.

Return type:

CatalogConfig

Returns:

The configuration with all problems found.