gitlabracadabra


Namegitlabracadabra JSON
Version 2.1.0 PyPI version JSON
download
home_pagehttps://gitlab.com/gitlabracadabra/gitlabracadabra
SummaryAdds some magic to GitLab
upload_time2024-03-06 15:50:17
maintainer
docs_urlNone
authorMathieu Parent
requires_python
licenseLGPL3
keywords gitlab api yaml
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Gitlabracadabra <!-- omit in toc -->

🧹 GitLabracadabra 🧙

:alembic: Adds some magic to GitLab :crystal\_ball:

GitLab'racadabra is a GitOps way to configure a [GitLab](https://gitlab.com/) instance
from a YAML configuration, using the [API](https://docs.gitlab.com/ce/api/README.html).

It is able to create GitLab's [groups](doc/group.md), [projects](doc/project.md),
[users](doc/user.md) and [application settings](doc/application_settings.md).

:thumbsup: It's also able to mirror :

- Git repositories, using the `mirrors` parameter in [Mirroring repositories](doc/project.md#mirroring-repositories).
- container (Docker) images, using the `image_mirrors` parameter. See [Mirroring container images](doc/image_mirrors.md).
- packages, using the `package_mirrors` parameter. See [Mirroring packages](doc/package_mirrors.md).

It is based on [Python GitLab](https://github.com/python-gitlab/python-gitlab).

## Table of Contents <!-- omit in toc -->

- [Installation](#installation)
  - [Using Debian packages](#using-debian-packages)
  - [Using pip](#using-pip)
  - [Using docker image](#using-docker-image)
  - [From source](#from-source)
- [Configuration](#configuration)
- [Action file(s)](#action-files)
- [Using gitlabracadabra in GitLab CI](#using-gitlabracadabra-in-gitlab-ci)
- [Contributing](#contributing)

## Installation

### Using Debian packages

Debian package is available [from artifacts](https://gitlab.com/gitlabracadabra/gitlabracadabra/-/jobs/artifacts/main/browse/debian/output?job=build-deb) and can be installed with:

```shell
apt install gitlabracadabra_*.deb

gitlabracadabra --verbose --dry-run
```

Note: Debian 11 bullseye or later is required.

### Using pip

```shell
pip install gitlabracadabra
```

### Using docker image

There are also [Docker/OCI images](https://gitlab.com/gitlabracadabra/gitlabracadabra/container_registry).

Example usage:

```shell
sudo docker run -ti \
  -v "$HOME/.python-gitlab.cfg:/home/gitlabracadabra/.python-gitlab.cfg:ro" \
  -v "$PWD/gitlabracadabra.yml:/app/gitlabracadabra.yml:ro" \
  'registry.gitlab.com/gitlabracadabra/gitlabracadabra:v2.1.0' \
  --verbose --dry-run
```

Other images are available. Examples:

- `registry.gitlab.com/gitlabracadabra/gitlabracadabra/main`: Current `main`
- `registry.gitlab.com/gitlabracadabra/gitlabracadabra/main:b1cd3482bf9583c5db863c359e12cafcdb7119bf`: A specific commit of `main`

### From source

Local installation (in `$HOME/.local`):

```shell
# On Debian or Ubuntu
sudo apt install -y --no-install-recommends \
  python3-build \
  python3-github \
  python3-gitlab \
  python3-html5lib \
  python3-jsonschema \
  python3-packaging \
  python3-pygit2 \
  python3-semantic-version \
  python3-vcr \
  python3-venv \
  python3-yaml \
  python3-pip \
  python3-coverage \
  python3-pytest
# On Alpine
sudo apk add \
  py3-build \
  py3-pygithub \
  py3-requests-toolbelt \
  py3-html5lib \
  py3-jsonschema \
  py3-packaging \
  py3-pygit2 \
  py3-semantic-version \
  py3-vcrpy \
  py3-yaml \
  py3-pip \
  py3-coverage \
  py3-pytest
# On others
pip install build

# Build and install
python3 -m build
version="$(grep __version__ gitlabracadabra/__init__.py  | awk -F "'" '{print $2}')"
pip install --user "dist/gitlabracadabra-$version"*.whl

# Test
pytest-3  # or pytest
~/.local/bin/gitlabracadabra --verbose --dry-run
```

## Configuration

GitLabracadabra uses the same configuration file as Python GitLab CLI to store
connection parameters.

Example `~/.python-gitlab.cfg`:

```ini
[global]
default = gitlab

[gitlab]
url = https://gitlab.com
private_token = T0K3N
```

More information in [Python GitLab documentation](https://python-gitlab.readthedocs.io/en/stable/cli-usage.html#content).

## Action file(s)

GitLabracadabra *actions* are configured with a YAML file.

See [GitLabracadabra's own action file](https://gitlab.com/gitlabracadabra/gitlabracadabra/blob/main/gitlabracadabra.yml)
or read:

- [Action file syntax](doc/action_file.md)
- list of parameters:
  - [for projects](doc/project.md)
  - [for groups](doc/group.md)
  - [for users](doc/user.md)
  - [for application settings](doc/application_settings.md)

## Using gitlabracadabra in GitLab CI

Since job token probably won't have enough permissions, you'll need to use a personal access token:

- [create a personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#creating-a-personal-access-token)
- [Define](https://docs.gitlab.com/ee/ci/variables/README.html#create-a-custom-variable-in-the-ui) the
`GITLAB_PRIVATE_TOKEN` **protected** variable
- Use it in your jobs to configure `python-gitlab`. Example `.gitlab-ci.yml`:

```yaml
default:
  image:
    name: 'registry.gitlab.com/gitlabracadabra/gitlabracadabra:v2.1.0'
    entrypoint: [""]
  before_script:
    - |
        cat << EOF > ~/.python-gitlab.cfg
        [global]
        default = gitlab
        [gitlab]
        url = ${CI_SERVER_URL:-https://gitlab.com}
        private_token = ${GITLAB_PRIVATE_TOKEN}
        # job_token = ${GITLAB_JOB_TOKEN}
        EOF

stages:
  - test
  - deploy

test:
  stage: test
  script:
    - gitlabracadabra --verbose --dry-run
  rules:
    - if: '$CI_COMMIT_BRANCH != "main"'

apply:
  stage: deploy
  script:
    - gitlabracadabra --verbose
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
```

## Contributing

- File bugs and feature requests in
  [GitLab issues](https://gitlab.com/gitlabracadabra/gitlabracadabra/-/issues).
  Security issues should be marked as **confidential**.
- Propose documentation or code improvements in
  [GitLab merge requests](https://gitlab.com/gitlabracadabra/gitlabracadabra/-/merge_requests).

  This repository enforces commit message convention, to check this locally install the
  [commitlint](https://github.com/conventional-changelog/commitlint/#what-is-commitlint)
  hook:

  ```shell
  npm install  @commitlint/{config-conventional,cli}
  echo 'npx commitlint --edit' >> .git/hooks/commit-msg
  chmod +x .git/hooks/commit-msg
  ```

See also:

- Setting up [a development environment](doc/dev_setup.md)
- [Configuring VS code](doc/vscode.md)
- [Releasing GitLabracadabra](doc/release.md).

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/gitlabracadabra/gitlabracadabra",
    "name": "gitlabracadabra",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "gitlab api yaml",
    "author": "Mathieu Parent",
    "author_email": "math.parent@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/1c/68/839d9ad7d8d9b95bbe066b087d659a91364d1a2f9fabb3b34692d084c98d/gitlabracadabra-2.1.0.tar.gz",
    "platform": null,
    "description": "# Gitlabracadabra <!-- omit in toc -->\n\n\ud83e\uddf9 GitLabracadabra \ud83e\uddd9\n\n:alembic: Adds some magic to GitLab :crystal\\_ball:\n\nGitLab'racadabra is a GitOps way to configure a [GitLab](https://gitlab.com/) instance\nfrom a YAML configuration, using the [API](https://docs.gitlab.com/ce/api/README.html).\n\nIt is able to create GitLab's [groups](doc/group.md), [projects](doc/project.md),\n[users](doc/user.md) and [application settings](doc/application_settings.md).\n\n:thumbsup: It's also able to mirror :\n\n- Git repositories, using the `mirrors` parameter in [Mirroring repositories](doc/project.md#mirroring-repositories).\n- container (Docker) images, using the `image_mirrors` parameter. See [Mirroring container images](doc/image_mirrors.md).\n- packages, using the `package_mirrors` parameter. See [Mirroring packages](doc/package_mirrors.md).\n\nIt is based on [Python GitLab](https://github.com/python-gitlab/python-gitlab).\n\n## Table of Contents <!-- omit in toc -->\n\n- [Installation](#installation)\n  - [Using Debian packages](#using-debian-packages)\n  - [Using pip](#using-pip)\n  - [Using docker image](#using-docker-image)\n  - [From source](#from-source)\n- [Configuration](#configuration)\n- [Action file(s)](#action-files)\n- [Using gitlabracadabra in GitLab CI](#using-gitlabracadabra-in-gitlab-ci)\n- [Contributing](#contributing)\n\n## Installation\n\n### Using Debian packages\n\nDebian package is available [from artifacts](https://gitlab.com/gitlabracadabra/gitlabracadabra/-/jobs/artifacts/main/browse/debian/output?job=build-deb) and can be installed with:\n\n```shell\napt install gitlabracadabra_*.deb\n\ngitlabracadabra --verbose --dry-run\n```\n\nNote: Debian 11 bullseye or later is required.\n\n### Using pip\n\n```shell\npip install gitlabracadabra\n```\n\n### Using docker image\n\nThere are also [Docker/OCI images](https://gitlab.com/gitlabracadabra/gitlabracadabra/container_registry).\n\nExample usage:\n\n```shell\nsudo docker run -ti \\\n  -v \"$HOME/.python-gitlab.cfg:/home/gitlabracadabra/.python-gitlab.cfg:ro\" \\\n  -v \"$PWD/gitlabracadabra.yml:/app/gitlabracadabra.yml:ro\" \\\n  'registry.gitlab.com/gitlabracadabra/gitlabracadabra:v2.1.0' \\\n  --verbose --dry-run\n```\n\nOther images are available. Examples:\n\n- `registry.gitlab.com/gitlabracadabra/gitlabracadabra/main`: Current `main`\n- `registry.gitlab.com/gitlabracadabra/gitlabracadabra/main:b1cd3482bf9583c5db863c359e12cafcdb7119bf`: A specific commit of `main`\n\n### From source\n\nLocal installation (in `$HOME/.local`):\n\n```shell\n# On Debian or Ubuntu\nsudo apt install -y --no-install-recommends \\\n  python3-build \\\n  python3-github \\\n  python3-gitlab \\\n  python3-html5lib \\\n  python3-jsonschema \\\n  python3-packaging \\\n  python3-pygit2 \\\n  python3-semantic-version \\\n  python3-vcr \\\n  python3-venv \\\n  python3-yaml \\\n  python3-pip \\\n  python3-coverage \\\n  python3-pytest\n# On Alpine\nsudo apk add \\\n  py3-build \\\n  py3-pygithub \\\n  py3-requests-toolbelt \\\n  py3-html5lib \\\n  py3-jsonschema \\\n  py3-packaging \\\n  py3-pygit2 \\\n  py3-semantic-version \\\n  py3-vcrpy \\\n  py3-yaml \\\n  py3-pip \\\n  py3-coverage \\\n  py3-pytest\n# On others\npip install build\n\n# Build and install\npython3 -m build\nversion=\"$(grep __version__ gitlabracadabra/__init__.py  | awk -F \"'\" '{print $2}')\"\npip install --user \"dist/gitlabracadabra-$version\"*.whl\n\n# Test\npytest-3  # or pytest\n~/.local/bin/gitlabracadabra --verbose --dry-run\n```\n\n## Configuration\n\nGitLabracadabra uses the same configuration file as Python GitLab CLI to store\nconnection parameters.\n\nExample `~/.python-gitlab.cfg`:\n\n```ini\n[global]\ndefault = gitlab\n\n[gitlab]\nurl = https://gitlab.com\nprivate_token = T0K3N\n```\n\nMore information in [Python GitLab documentation](https://python-gitlab.readthedocs.io/en/stable/cli-usage.html#content).\n\n## Action file(s)\n\nGitLabracadabra *actions* are configured with a YAML file.\n\nSee [GitLabracadabra's own action file](https://gitlab.com/gitlabracadabra/gitlabracadabra/blob/main/gitlabracadabra.yml)\nor read:\n\n- [Action file syntax](doc/action_file.md)\n- list of parameters:\n  - [for projects](doc/project.md)\n  - [for groups](doc/group.md)\n  - [for users](doc/user.md)\n  - [for application settings](doc/application_settings.md)\n\n## Using gitlabracadabra in GitLab CI\n\nSince job token probably won't have enough permissions, you'll need to use a personal access token:\n\n- [create a personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#creating-a-personal-access-token)\n- [Define](https://docs.gitlab.com/ee/ci/variables/README.html#create-a-custom-variable-in-the-ui) the\n`GITLAB_PRIVATE_TOKEN` **protected** variable\n- Use it in your jobs to configure `python-gitlab`. Example `.gitlab-ci.yml`:\n\n```yaml\ndefault:\n  image:\n    name: 'registry.gitlab.com/gitlabracadabra/gitlabracadabra:v2.1.0'\n    entrypoint: [\"\"]\n  before_script:\n    - |\n        cat << EOF > ~/.python-gitlab.cfg\n        [global]\n        default = gitlab\n        [gitlab]\n        url = ${CI_SERVER_URL:-https://gitlab.com}\n        private_token = ${GITLAB_PRIVATE_TOKEN}\n        # job_token = ${GITLAB_JOB_TOKEN}\n        EOF\n\nstages:\n  - test\n  - deploy\n\ntest:\n  stage: test\n  script:\n    - gitlabracadabra --verbose --dry-run\n  rules:\n    - if: '$CI_COMMIT_BRANCH != \"main\"'\n\napply:\n  stage: deploy\n  script:\n    - gitlabracadabra --verbose\n  rules:\n    - if: '$CI_COMMIT_BRANCH == \"main\"'\n```\n\n## Contributing\n\n- File bugs and feature requests in\n  [GitLab issues](https://gitlab.com/gitlabracadabra/gitlabracadabra/-/issues).\n  Security issues should be marked as **confidential**.\n- Propose documentation or code improvements in\n  [GitLab merge requests](https://gitlab.com/gitlabracadabra/gitlabracadabra/-/merge_requests).\n\n  This repository enforces commit message convention, to check this locally install the\n  [commitlint](https://github.com/conventional-changelog/commitlint/#what-is-commitlint)\n  hook:\n\n  ```shell\n  npm install  @commitlint/{config-conventional,cli}\n  echo 'npx commitlint --edit' >> .git/hooks/commit-msg\n  chmod +x .git/hooks/commit-msg\n  ```\n\nSee also:\n\n- Setting up [a development environment](doc/dev_setup.md)\n- [Configuring VS code](doc/vscode.md)\n- [Releasing GitLabracadabra](doc/release.md).\n",
    "bugtrack_url": null,
    "license": "LGPL3",
    "summary": "Adds some magic to GitLab",
    "version": "2.1.0",
    "project_urls": {
        "Homepage": "https://gitlab.com/gitlabracadabra/gitlabracadabra"
    },
    "split_keywords": [
        "gitlab",
        "api",
        "yaml"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f59a2e7063ac5abcc77afbb100b484f3b7af543dd855c7b46736bc551b0a529a",
                "md5": "f22a347e3c5409f08c3ad4edc82169c4",
                "sha256": "a31714e35accf2dbb1f58ac82d7d8e48f9d5b21ca4e13783f5b73c7e9db48dda"
            },
            "downloads": -1,
            "filename": "gitlabracadabra-2.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f22a347e3c5409f08c3ad4edc82169c4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 663318,
            "upload_time": "2024-03-06T15:50:14",
            "upload_time_iso_8601": "2024-03-06T15:50:14.117735Z",
            "url": "https://files.pythonhosted.org/packages/f5/9a/2e7063ac5abcc77afbb100b484f3b7af543dd855c7b46736bc551b0a529a/gitlabracadabra-2.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c68839d9ad7d8d9b95bbe066b087d659a91364d1a2f9fabb3b34692d084c98d",
                "md5": "3a13ea52f6aaa1ee32309fb894ce61bb",
                "sha256": "e5f3cefcbaa6b01804fba9054362eadb004777c54fc184c9089226d23ad345a5"
            },
            "downloads": -1,
            "filename": "gitlabracadabra-2.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3a13ea52f6aaa1ee32309fb894ce61bb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 467067,
            "upload_time": "2024-03-06T15:50:17",
            "upload_time_iso_8601": "2024-03-06T15:50:17.075484Z",
            "url": "https://files.pythonhosted.org/packages/1c/68/839d9ad7d8d9b95bbe066b087d659a91364d1a2f9fabb3b34692d084c98d/gitlabracadabra-2.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-06 15:50:17",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "gitlabracadabra",
    "gitlab_project": "gitlabracadabra",
    "lcname": "gitlabracadabra"
}
        
Elapsed time: 0.19510s