Commit 14c13299 authored by Brennen Bearnes's avatar Brennen Bearnes
Browse files

stub out configure-projects command, fill out README.md a bit

`configure-projects` uses the python-gitlab project to loop over all
projects in the instance and disable issues and wikis.

This also adds a requirements.txt and some rudimentary instructions in the
README.
parent ea4e1e2d
gitlab-settings gitlab-settings
=============== ===============
A collection of GitLab CE settings, and a Python script for applying them via A collection of GitLab CE settings for the [Wikimedia GitLab instance][wmf-gl],
[the settings API][gl-settings]. along with Python utilities for applying them via [the settings
API][gl-settings].
[gl-settings]: https://docs.gitlab.com/ce/api/settings.html [gl-settings]: https://docs.gitlab.com/ce/api/settings.html
[wmf-gl]: https://gitlab.wikimedia.org/
Installing
----------
```sh
pip3 install -r requirements.txt
```
Usage
-----
View current instance settings:
```sh
./view-settings
```
Apply instance settings from `settings.yaml`:
```sh
./apply-settings
```
Apply project settings (at the moment, this disables wikis and issue tracking
for any projects that have turned it on):
```sh
./configure-projects
```
#!/usr/bin/env python3
"""
configure-projects - apply settings to all projects on GitLab instance
"""
import os
import sys
import yaml
import argparse
import gitlab
import time
from gitlab_settings.util import get_token
def get_gitlab():
"""Get a GitLab instance."""
token = get_token()
print(token)
server = gitlab.Gitlab('https://gitlab.wikimedia.org/', private_token=token)
return server
def get_projects():
"""Get all projects on the server as a generator."""
server = get_gitlab()
return server.projects.list(all=True, as_list=False)
for project in get_projects():
if project.issues_access_level != 'disabled':
print('Disabling issue access for ', project.name)
project.issues_access_level = 'disabled'
project.save()
else:
print('Issues already disabled for ', project.name)
if project.wiki_access_level != 'disabled':
print('Disabling wiki access for', project.name)
project.wiki_access_level = 'disabled'
project.save()
else:
print('Wiki already disabled for', project.name)
time.sleep(.5)
...@@ -13,7 +13,7 @@ import sys ...@@ -13,7 +13,7 @@ import sys
import yaml import yaml
from gitlab_settings.util import get_token from gitlab_settings.util import get_token
token = get_token token = get_token()
url = 'https://gitlab.wikimedia.org/api/v4/application/settings' url = 'https://gitlab.wikimedia.org/api/v4/application/settings'
headers = { headers = {
'User-Agent': 'gitlab-settings/0.0.1', 'User-Agent': 'gitlab-settings/0.0.1',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment