Skip to main content

Easy configuration as code tool for GitLab using config in plain YAML

Project description

PyPI version Build Status

GitLabForm

Join the chat at https://gitter.im/egnyte/gitlabform

GitLabForm is an easy configuration as code tool for GitLab using config in plain YAML.

Features

GitLabForm enables you to manage:

  • Project settings,

  • Deployment keys,

  • Secret variables,

  • Branches (protect/unprotect),

  • Services,

  • (Project) Hooks,

  • (Add/edit or delete) Files, with simple templating,

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

…for:

  • all projects you have access to,

  • a group of projects,

  • a single project,

…and a combination of them (default config for all projects + more specific for some groups + even more specific for particular projects).

Quick start

  1. Install with: pip3 install gitlabform

  2. Create example config.yml:

gitlab:
  url: https://gitlab.yourcompany.com
  token: "<private token of an admin user>"
  api_version: 4

group_settings:
  'my_group':
    deploy_keys:
      a_friendly_deploy_key_name:
        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/reset this deploy key to all projects in “my_group” group in your GitLab!

Configuration syntax

See config.yml in this repo as a well documented example of configuring all projects in all groups, projects in “my_group” group and specifically project “my_group/my_project1”.

More 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

If you are satisfied with results consider running it with cron on a regular basis to ensure that your GitLab configuration stays the way defined in your config (for example in case of some admin changes some project settings temporarily by (yuck!) clicking).

All command line parameters

Run:

gitlabform -h

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

Requirements

  • Python 3.5+

  • GitLab 11+ for gitlabform >=1.0.0, GitLab 9.1-10.8 for gitlabform <1.0.0, (GitLab EE 10.6+ for merge_requests section)

Why?

This tool was 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 configuration as code.

GitLabForm is slightly similar to GitLab provider for Terraform (which we love, btw!), but it has much more features and uses simpler configuration format.

How does it work?

It just goes through a loop of projects list and make a series of GitLab API requests. Where possible it corresponds to GitLab API 1-to-1, so for example it just PUTs or POSTs the hash set at given place in its config transformed into JSON, so that it’s not necessary to modify the app in case of some GitLab API changes.

Contributing

Development environment setup how-to:

  1. Install build requirements - pandoc binary package + pypandoc python package.

  2. Create virtualenv with Python 3.5+, for example in venv dir which is in .gitignore.

  3. Activate the virtualenv and install gitlabform in it in develop mode (python setup.py develop).

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.0.7.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

gitlabform-1.0.7-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file gitlabform-1.0.7.tar.gz.

File metadata

  • Download URL: gitlabform-1.0.7.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.5.6

File hashes

Hashes for gitlabform-1.0.7.tar.gz
Algorithm Hash digest
SHA256 96c865fa20ce0982499924a7a250131e76f9915948533627eca04c8b153f00b5
MD5 fde28c328b13379b41c90a32f59fc431
BLAKE2b-256 c418dfa7cd58ce4cf3d8a0bd5143a700d64dd25f97a34b199722891169b64441

See more details on using hashes here.

File details

Details for the file gitlabform-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: gitlabform-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.5.6

File hashes

Hashes for gitlabform-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f0c3261857c75ba9bff922605bf981633e60fdf72ed9b54e9d60bed8dc72ca92
MD5 4e7b2a6f9ff6f7c29bc9598b91e5338b
BLAKE2b-256 8e5fc65b5a5f4b04aa91fc15d624a834ab5a61bae14f224e4818fddd0786fc4f

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