app.sources.gitlab_settings

Settings of the gitlab source type, validated without I/O.

Parses the type-specific options (base_url, token_env), the scope and the published_ref of a registration into a GitLabConfig; see app.sources.gitlab for their meaning. The token is resolved from the injected environment and held as a pydantic.SecretStr; messages name the env var only.

Public API: PROJECT_DEFAULT, GitLabScope, GitLabConfig, parse_settings().

app.sources.gitlab_settings.PROJECT_DEFAULT = '@project-default'

published_ref value selecting each project’s default branch.

class app.sources.gitlab_settings.GitLabScope(groups, include_subgroups, projects)

Bases: object

Which projects a registration owns.

Parameters:
  • groups (frozenset[str]) – Casefolded group paths.

  • include_subgroups (bool) – Whether descendant namespaces count.

  • projects (frozenset[str]) – Casefolded explicit project paths.

groups: frozenset[str]
include_subgroups: bool
projects: frozenset[str]
contains(project)

Tell whether a project path is in scope.

Parameters:

project (str) – Full project path (group/sub/project).

Return type:

bool

Returns:

True if listed explicitly or under a scoped group.

class app.sources.gitlab_settings.GitLabConfig(*, base_url, token, token_env, scope, groups, projects, path, published_ref)

Bases: object

Validated settings of one gitlab registration.

Parameters:
  • base_url (str) – Instance URL without trailing slash.

  • token (SecretStr) – Access token.

  • token_env (str) – Env var name of the token (for messages).

  • scope (GitLabScope) – Scope predicate.

  • groups (tuple[str, ...]) – Configured group paths, as written.

  • projects (tuple[str, ...]) – Configured project paths, as written.

  • path (str) – ADR path inside each project (may be empty).

  • published_ref (str) – Branch name or PROJECT_DEFAULT.

base_url: str
token: SecretStr
token_env: str
scope: GitLabScope
groups: tuple[str, ...]
projects: tuple[str, ...]
path: str
published_ref: str
app.sources.gitlab_settings.parse_settings(settings, env)

Validate a gitlab registration (no I/O).

Parameters:
  • settings (SourceSettings) – Common settings plus options and scope.

  • env (Mapping[str, str]) – Environment used to resolve token_env.

Return type:

GitLabConfig

Returns:

The configuration.

Raises:

SourceConfigError – If the settings are invalid or the token env var is not set (the value is never echoed).