guard module

The guard module.

class confirm.gitlab_guard.guard.Guard(url, token, namespace, fix)

The main GitLab Guard class which does all the heavy load.

Parameters:
  • url (str) – The GitLab URL

  • token (str) – The GitLab token

  • namespace (str) – The GitLab namespace

  • fix (bool) – Fix violations automatically

init_defaults()

Initialise the default configuration, retreived from the defaults.yml contained in the GitLab Guard Python module.

init_gitlab()

Initialise the GitLab instance.

Raises:

InitError – When URL or token is missing

init_overrides()

Retreive the project overrides from the project’s .gitlab-guard.yml file.

The .gitlab-guard.yml is looked up in the default branch on the root level of the project’s repository. It must be a valid YAML file.

init_projects()

Retreive all unarchived GitLab projects, sorted by their path in an ascending order.

run()

Run the GitLab Guard.

Raises:

InitError – When an error during the initialisation occurs

verify_overrides(overrides)

Verify the overrides.

Parameters:

overrides (dict) – The overrides

Raises:

OverrideError – When validation failed

verify_projects()

Verify all projects.

Raises:

UpdateError – When there was a GitLab error

verify_protected_branches(project)

Verify the protected branches of a project.

Parameters:

project (gitlab.v4.objects.projects.Project) – The project

verify_protected_tags(project)

Verify the protected tags of a project.

Parameters:

project (gitlab.v4.objects.projects.Project) – The project

verify_settings(project)

Verify the project settings.

Parameters:

project (gitlab.v4.objects.projects.Project) – The project