Skip to main content

Specialized "configuration as a code" tool for GitLab projects, groups and more using hierarchical configuration written in YAML

Project description

version release date PyPI downloads docker pulls code style

GitLabForm

GitLabForm is a specialized “configuration as a code” tool for GitLab projects, groups and more using hierarchical configuration written in YAML.

Table of Contents

Features

GitLabForm enables you to manage:

  • Group settings,

  • Project settings,

  • Archive/unarchive project,

  • Project members (users and groups) {add/change access level, NO removal yet},

  • Group members (users) {add/remove user, change access level},

  • Deployment keys,

  • Secret variables (on project and group/subgroup level),

  • Branches (protect/unprotect),

  • Tags (protect/unprotect),

  • Services,

  • (Project) Hooks,

  • (Project) Push Rules (GitLab EE only),

  • (Add/edit or delete) Files, with templating based on Jinja2 (now supports custom variables!),

  • Merge Requests approvals settings and approvers (GitLab EE only),

  • Pipeline schedules,

…for:

  • all projects in your GitLab instance/that you have access to,

  • a group/subgroup of projects,

  • a single project,

…and a combination of them.

GitLabForm uses hierarchical configuration with inheritance, merging/overwriting and addivity. GitLabForm is also using passing the parameters as-is to GitLab APIs with PUT/POST requests.

Comparison to similar apps

GitLabForm has roughly the same purpose as GitLab provider for Terraform (which is a tool that we love and which has inspired us to write this app), but it has a different set of features and uses a different configuration format.

Please read more about GitLab provider for Terraform vs GitLabForm. This article includes a link to the feature matrix / comparison sheet between these two tools.

To configure your GitLab instance itself (appearance, application settings, features, license) please check out the GitLab Configuration as Code (GCasC) project!

Limitations

Some of the app features are limited because of the GitLab API issues. Here is the list of them. Please check the links to the GitLab issue(s) in their comments and please upvote them if they are affecting you. Note that these issues/bugs affect all the apps using GitLab API, not just GitLabForm.

Requirements

  • Python 3.6-3.8 or Docker

    • (Python 3.9 should be fine too, but it’s not “officially” supported yet)

  • GitLab 11+, GitLab EE for Merge Requests & Push Rules management

Installation

  1. Pip: pip3 install gitlabform

B. Docker: run GitLabForm in a Docker container with this oneliner: docker run -it -v $(pwd):/config egnyte/gitlabform:latest gitlabform. Instead of “latest” you can also use a specific version and choose from Alpine and Debian-based images. See the GitLabForm’s DockerHub page for a list of available tags.

Quick start

Let’s assume that you want to add a deployment key to all projects in a group “My Group” (with path “my-group”). If so then:

  1. Create example config.yml:

gitlab:
  # You can also set in your environment GITLAB_URL
  url: https://gitlab.yourcompany.com
  # You can also set in your environment GITLAB_TOKEN
  token: "<private token of an admin user>"
  api_version: 4

group_settings:
  my-group:
    deploy_keys:
      a_friendly_deploy_key_name:  # this name is only used in GitLabForm config
        key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3WiHAsm2UTz2dU1vKFYUGfHI1p5fIv84BbtV/9jAKvZhVHDqMa07PgVtkttjvDC8bA1kezhOBKcO0KNzVoDp0ENq7WLxFyLFMQ9USf8LmOY70uV/l8Gpcn1ZT7zRBdEzUUgF/PjZukqVtuHqf9TCO8Ekvjag9XRfVNadKs25rbL60oqpIpEUqAbmQ4j6GFcfBBBPuVlKfidI6O039dAnDUsmeafwCOhEvQmF+N5Diauw3Mk+9TMKNlOWM+pO2DKxX9LLLWGVA9Dqr6dWY0eHjWKUmk2B1h1HYW+aUyoWX2TGsVX9DlNY7CKiQGsL5MRH9IXKMQ8cfMweKoEcwSSXJ
        title: ssh_key_name_that_is_shown_in_gitlab
        can_push: false
  1. Run gitlabform my-group

  2. Watch GitLabForm add this deploy key to all projects in “My Group” group in your GitLab!

Full configuration syntax

See config.yml in this repo as a well documented example of all the features, including configuring all projects in all groups, projects in “my-group” group and specifically project “my-group/my-project1”.

More cli usage examples

To apply settings for a single project, run:

gitlabform my-group/my-project1

To apply settings for a group of projects, run:

gitlabform my-group

To apply settings for all groups of projects and projects explicitly defined in the config, run:

gitlabform ALL_DEFINED

To apply settings for all projects, run:

gitlabform ALL

Run:

gitlabform -h

…to see the current set of supported command line parameters.

Running in an automated pipeline

You can use GitLabForm as a part of your CCA (Continuous Configuration Automation) pipeline.

For example, you can run it: * with a schedule on ALL_DEFINED or ALL projects to unify your GitLab configuration, after it may have drifted from the configuration (we recommend running it each night), * from a webhook after a new project is created in GitLab to initialize it with a shared config.

An example for running GitLabForm using GitLab CI is provided in the .gitlab-ci.example.yml file.

Note that as a standard best practice you should not put your GitLab access token in your config.yml (unless it is encrypted) for security reasons - please set it in the GITLAB_TOKEN environment variable instead.

For GitLab CI a secure place to set it would be a Secret/Protected Variable in the project configuration.

Contributing

Please see the contribution guide for info about all kinds of contributions, like: * questions, feature requests, * documentation and code contributions, * other.

Contribution guide is also the place to look for info how to develop the app locally, build it, run the tests and learn about the code guidelines.

For detailed info about how the app code has been organized, where is what and where and how to fix bugs and/or add new features, please see the implementation design article.

History

This tool has been originally created as a workaround for missing GitLab features such as assigning deploy keys per project groups but as of now we prefer to use it ever if there are appropriate web UI features, such as secret variables per project groups (released in GitLab 9.4) to keep the configuration as code.

Later on we added features that allowed us to use GitLabForm to improve a group containing around 100 similar projects to move to a unified development flow (by managing branches protection and the Pull Requests configuration), basic tests and deployment process (by managing secret variables, deployment keys and files, such as .gitlab-ci.yml), integrations (such as JIRA or Slack) and more.

License

MIT

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitlabform-1.20.0rc1.tar.gz (44.3 kB view details)

Uploaded Source

Built Distribution

gitlabform-1.20.0rc1-py3-none-any.whl (61.7 kB view details)

Uploaded Python 3

File details

Details for the file gitlabform-1.20.0rc1.tar.gz.

File metadata

  • Download URL: gitlabform-1.20.0rc1.tar.gz
  • Upload date:
  • Size: 44.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for gitlabform-1.20.0rc1.tar.gz
Algorithm Hash digest
SHA256 2ecac84ee50823a733836efb3ec4a8970ea4207248844db54556926c9042f2e2
MD5 9bf9b9553f39b7574ac38b80efd48fc1
BLAKE2b-256 9ec56a7017a80c87d090fd31bfd2442dfc7162f0dd6cfeaa1c01c74d4abbb140

See more details on using hashes here.

File details

Details for the file gitlabform-1.20.0rc1-py3-none-any.whl.

File metadata

  • Download URL: gitlabform-1.20.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 61.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for gitlabform-1.20.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 9b46c189307bb1e6dd9d091eddc05a52807b6a4e8a8f26752aeb44518c26e0ba
MD5 a229970a5d64e7adc9e7535a28711e03
BLAKE2b-256 f4d74f8a33394143796c1cedb033128bca447a7bec3251cdaf5d4e20c9ef2020

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page