Categorygithub.com/erinkerncs/gitlab-settings-enforcer
modulepackage
0.0.0-20191127191053-5cb30608cc26
Repository: https://github.com/erinkerncs/gitlab-settings-enforcer.git
Documentation: pkg.go.dev

# README

GitLab Settings Enforcer

Enforces GitLab project settings by reading a config file and talking to the GitLab API(s).

Usage

T.B.D.

Configuration

Configuration of project interaction is currently possible via JSON files providing a Config object. The config object has the following fields:

FieldTypeRequiredContentDefault
group_namestringyesThe path of the root group
(e.g. example or some/nested/example)
project_blacklist[]stringnoA list of projects to blacklist
(cannot be set when project_whitelist is used)
[]
project_whitelist[]stringnoA list of projects to whitelist
(cannot be set when project_blacklist is used)
[]
create_default_branchboolnoWhether the default branch configured in project_settings.default_branch should be created if it doesn't exist
protected_branches[]ProtectedBranchnoA list of branches to protect, together with the infos which roles are allowed to merge or push.
approval_settingsObjectnoThe gitlab project approval settings to change. Possible keys
project_settingsObjectnoThe gitlab project settings to change. Possible keys
complianceObjectnoThe compliance configuration.

ProtectedBranch

FieldTypeRequiredContent
namestringyesThe name of the branch to protect
push_access_levelstringyesWhich role is allowed to push (possible values: maintainer, developer, noone)
merge_access_levelstringyesWhich role is allowed to merge (possible values: maintainer, developer, noone)

Compliance

FieldTypeRequiredContent
mandatoryObjectyesSetting names, and their values following the sync naming schema

Env vars

To control the GitLab API endpoint and the authentication as well as further internal flags please use the following env vars:

NameRequiredDescriptionDefault
GITLAB_ENDPOINTnoOnly override when using GitLab on premise, set this to your GitLab Server Domain(gitlab.com)
GITLAB_TOKENyesThe GitLab API token used for authentication
VERBOSEnoEnables debug logging when enabledfalse

Config Example

An example SYNC config might look like the following:

{
  "group_name": "example",
  "project_blacklist": [
    "example/path-to/ignored-project"
  ],
  "project_whitelist": [],
  "create_default_branch": true,
  "protected_branches": [
    { "name": "develop", "push_access_level": "maintainer", "merge_access_level": "developer"},
    { "name": "master", "push_access_level": "maintainer", "merge_access_level": "developer"}
  ],
  "approval_settings": {
    "disable_overriding_approvers_per_merge_request": false,
    "merge_requests_author_approval": false,
    "merge_requests_disable_committers_approval": true,
    "reset_approvals_on_push": true
  },
  "project_settings": {
    "default_branch": "develop",
    "issues_enabled": true,
    "merge_requests_enabled": true,
    "jobs_enabled": true,
    "wiki_enabled": false,
    "snippets_enabled": false,
    "resolve_outdated_diff_discussions": true,
    "container_registry_enabled": true,
    "shared_runners_enabled": false,
    "only_allow_merge_if_pipeline_succeeds": false,
    "only_allow_merge_if_all_discussions_are_resolved": true,
    "merge_method": "merge",
    "public_builds": false,
    "lfs_enabled": true,
    "request_access_enabled": false,
    "tag_list": [],
    "printing_merge_request_link_enabled": true,
    "ci_config_path": null,
    "approvals_before_merge": 1
  }
}

An example COMPLIANCE config might look like the following:

{
  "compliance": {
    "mandatory": {
      "approval_settings": {
        "reset_approvals_on_push": false
      },
      "project_settings": {
        "resolve_outdated_diff_discussions": false
      }
    }
  }
}

License

MIT License

Copyright (c) 2019 Scalify GmbH
Copyright (c) 2019 Eric Rinker

# Packages

No description provided by the author