Giter VIP home page Giter VIP logo

concierge-cli's Introduction

Concierge-cli Latest version on PyPI

GitHub Workflow Status GitHub Workflow Status Code health Python versions Software license

Companion CLI for Concierge, the Configuration management & CI solution for aligning your multitude of Git repositories. Allows you to bulk-manage properties of your Git repository projects. Currently, GitLab is supported.

Why Should I Use This Tool?

Concierge-cli helps you analyze and bulk-update the repository projects you manage (e.g. set topics on projects, generate project lists for ModuleSync).

Installation

From PyPI:

$ pip install concierge-cli

Note: You need Python >= 3.6, otherwise your installation will not succeed (python-gitlab v2.0.0 dropped support for older Pythons). You can use Pipenv to work around this limitation:

$ pip install pipenv
$ pipenv shell --three
$ pip install concierge-cli

Preparation

You need an access token of a GitLab user to access resources through the API. For groups and group membership this needs to be an administrator user. You may also want to disable notifications of the user(s) you plan to perform bulk updates on, to avoid sending out massive amounts of emails.

Set the GitLab URI and TOKEN as environment variables (if you want to avoid using the --token and/or --uri options):

$ export CONCIERGE_GITLAB_URI=https://git.example.com/
$ export CONCIERGE_GITLAB_TOKEN=<redacted>

Usage Patterns

  1. Manage project topics
  2. List projects by topic
  3. List (and merge) merge requests by project
  4. Manage group membership and permissions

Manage topics

List all projects (for a private GitLab) that have no topics yet:

$ concierge-cli gitlab --uri https://git.vs.hn topics --empty

List all projects "foo" or similar in group "bar" or similar: (on GitLab.com)

$ concierge-cli gitlab topics bar/foo --empty

Set topics on all those projects:

$ concierge-cli gitlab topics bar/foo --empty --set-topic Puppet --set-topic Ansible

List all projects with topics now: (double-check)

$ concierge-cli gitlab topics bar/foo

List projects

Print a YAML list of all projects matching a topic:

$ concierge-cli gitlab projects --topic Puppet

Update the list of modules Concierge manages with a specific configuration:

$ concierge-cli gitlab projects --topic Puppet > configs/foo-bar/managed_modules.yml
$ git add -v configs/foo-bar/managed_modules.yml
$ git status && git commit -m 'Added ...' && git push

Merge requests

List of all merge requests of a project, optionally matching labels:

$ concierge-cli gitlab mrs mygroup/myproject --label mylabel

Add --merge yes to trigger merging all found requests.

Group membership

List all groups where user is not yet a member of:

$ concierge-cli gitlab groups --no-member my.user.name

Add user to all those groups:

$ concierge-cli gitlab groups --no-member my.user.name \
                       --set-permission maintainer

List a user's group memberships and permissions:

$ concierge-cli gitlab groups my.user.name

Remove a user from selected groups:

$ concierge-cli gitlab groups my.user.name \
                       --group-filter a-group-name \
                       --set-permission none

Found a bug? Need a new feature?

Please see our Contribution Guide if you want to help out!

concierge-cli's People

Contributors

anothertobi avatar basharsaid avatar bittner avatar psy-q avatar renovate-bot avatar renovate[bot] avatar thebiglee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

concierge-cli's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/check.yml
  • actions/checkout v3
  • actions/setup-python v4
.github/workflows/publish.yml
  • actions/checkout v3
  • actions/setup-python v4
.github/workflows/test.yml
  • actions/checkout v3
  • actions/setup-python v4
pip_requirements
requirements.txt
  • certifi ==2022.12.7
  • charset-normalizer ==3.1.0
  • click ==8.1.3
  • idna ==3.4
  • python-gitlab ==3.13.0
  • requests ==2.28.2
  • requests-toolbelt ==0.10.1
  • urllib3 ==1.26.15
pipenv
Pipfile

  • Check this box to trigger a request for Renovate to run again on this repository

Personal projects on GitLab are not found (known issue)

Symptoms

If I try to list my personal GitLab projects, e.g.

concierge-cli gitlab topics bittner/

or

concierge-cli gitlab mrs bittner/

then nothing is listed, even though I have several projects at https://gitlab.com/bittner/.

Explanation

The current implementation (Topicmanager, MergeRequestManager) loops over a list of groups to make easy filtering of groups and projects possible. It looks like the personal namespace is not considered as a Group for a GroupProject in in the GitLab API.

How to fix this?

If you think this is a problem that deserves fixing, please

  1. investigate the issue on the GitLab issue tracker first, and review the python-gitlab docs and related GitLab API docs
  2. comment here for a proposed solution
  3. create a PR to fix the implementation

PyUp Setup (Initial Update)

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Improve execution speed (e.g. use asyncio)

Due to GitLab's API design the CLI makes a lot of separate queries, which slows down the execution time. This is typically at least O(n ²) time due to nested loops combined with general slowness as API calls to an external service are performed each time.

This can most probably not be fixed via algorithmic changes, but requires parallelization. We may tackle this using Python's asyncio module. See the recording of Michael Kennedy's webinar for a good intro.

Allow `projects` command to logically AND-connect `--topic` values

Currently, the concierge-cli projects command allows to specify several --topic options to select all projects that match any of those values (i.e. the possible topic values are logically OR'ed).

Needed Features

  • It should be possible to alternatively specify several topics, which are the locally AND'ed to select only projects that have all of those topics set (as a subset).
  • Aligned with that, it should be possible to set the topics with the same topics syntax (in addition to using several --set-topic options)

Examples

concierge-cli gitlab projects --topic managed,waf,group::foobar
- mygroup/my-project-one
- another/my-project-two
concierge-cli gitlab topics /my-project- --set-topic one,two,three

Add `tag` command for bulk-tagging repositories

With our current release process we need to push a tag to all repositories we bulk-manage. On the GitLab Web frontend this is a bit time-consuming, and actually error-prone (you can easily overlook repositories).

On the command line we could easily do that quicker using just git, but we'd need to close every single repository. We should probably better do that via GitLab API calls.

Given that we'll release frequently and more in terms of "reflect the current state of are" (not in terms of release "features of a product") semver is likely less suitable as a versioning scheme than something that better reflects both a date/time "bandwidth" of release activities and blends in well in automated operations (e.g. increment last number when several releases need to be done). This might be a date-based scheme, e.g. YYYY.MM.c with c being a monthly release counter starting at 1 each month (or YY.MM.c like Ubuntu does it). EDIT: (see explanation below)

Needed Features

  • List latest tag(s) of a number of repository (e.g. project filtered by --topics), detecting whether there are unreleased commits
  • Set a tag on a number of repositories (as listed earlier)

Examples

(See comment below)

Allow token to be specified via environment variable

Currently, we have to specify the --token value as a CLI option for the gitlab command. That's not nice if we want to do, say, screen sharing in a video conference session.

It would be helpful if it we possible to specify the token only once by exporting an environment variable, e.g.

$ export CONCIERGE_GITLAB_TOKEN=jflsalgaslgkh
$ concierge-cli gitlab groups example-user
...

Similar for the --uri option, probably. This could be covered by CONCIERGE_GITLAB_URI, so a user wouldn't need to create a configuration file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.