e3_build_tools.git.registry¶
Module for interfacing the ESS Gitlab wrapper repositories.
Attributes¶
Classes¶
Interface to GitLab. |
|
Registry for wrappers and interface to GitLab. |
Module Contents¶
- class e3_build_tools.git.registry.GitLabInterface(address: str = ESS_GITLAB_URL, private_token: str | None = None, config: str | None = None, top_group: int = GITLAB_ID_E3_GROUP)[source]¶
Interface to GitLab.
- get_all_projects() List[gitlab.v4.objects.GroupProject][source]¶
Returns a list of all GroupProjects in the e3 space.
The object returned by
Gitlab.groups.get().projects.list()isGroupProject. This needs to be converted toProjectto have access to all attributes, but we do not convert at this stage (to keep down the number of calls).
- get_project_by_id(_id: int) gitlab.v4.objects.Project[source]¶
Return a GitLab
Projectobject based on the ID.Caches previous results to reduce the amount of API calls. We are using the Least Recently Used (LRU) cache but with no limit to the number of elements stored, effectively turning it into an unbound cache.
- get_current_user_id() int[source]¶
Return the current user ID.
- Raises:
GitlabAuthenticationError: If authentication is not correct.
- create_new_project(name: str, group_id: int) gitlab.v4.objects.Project[source]¶
Create a new GitLab project.
- Raises:
GitlabCreateError: If project already exists in the group.
- get_group_by_id(_id: int) gitlab.v4.objects.Group[source]¶
Return a GitLab
Groupobject based on the ID.Caches previous results to reduce the amount of API calls. We are using the Least Recently Used (LRU) cache but with no limit to the number of elements stored, effectively turning it into an unbound cache.
- class e3_build_tools.git.registry.WrapperRegistry(**kwargs)[source]¶
Bases:
GitLabInterfaceRegistry for wrappers and interface to GitLab.
The class stores information about the wrapper repositories, and implements the required interfaces to the ESS GitLab repositories.
- get_all_wrapper_projects() Dict[str, int][source]¶
Return a dictionary with the project id for each project.
The returned data is a dictionary with the project name as the keys, and the internal GitLab project ID as the data.
- get_project(name: str) gitlab.v4.objects.Project[source]¶
Return a GitLab
Projectobject based on the name.- Raises:
KeyError: If module name not found.
- get_project_id(name: str) int[source]¶
Return the GitLab ID for a project name.
- Raises:
KeyError: If module name not found.
- get_config_from(name: str, ref: str, *, file: str) str[source]¶
Return a module revision’s configuration.
The function fetches the configuration for a wrapper from the GitLab repository at a specified reference (e.g., commit hash, tag, branch).
- Raises:
MissingReferenceException: If the reference does not exists on the repository. FileNotFoundException: If
namedoes not exist or iffiledoes not exist for the given reference.
- read_version_from(name: str, ref: str, *, config: str, var: str, validate: bool = True) str[source]¶
Return the configured version for a version of a module.
- create_commit_payload(substitutions: Dict[str, Dict[str, str]], starting_reference: str, name: str, branch: str) GitLabCommitPayload[source]¶
Return representation of JSON data to be used by
commit_change().- Raises:
NoModuleChangesException: If there are no changes to be applied to the module.
- update_submodule(name: str, submodule_path: str, sha: str, branch: str) None[source]¶
Update the submodule reference.
- commit_change(name: str, payload: GitLabCommitPayload) gitlab.v4.objects.ProjectCommit[source]¶
Commit changes to project on gitlab.