API for managing pre-receive hooks
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem to solve
When setting up bidirectional repository mirroring, the official recommendation is to register a pre-receive hook in order to prevent race condition issues: https://docs.gitlab.com/ee/user/project/repository/repository_mirroring.html#preventing-conflicts-using-a-pre-receive-hook
In our setup, we use a dedicated GitLab group for managing MachineLearning datasets, with 1 repo per dataset. Repositories are created automatically, bidirectional mirroring to/from CodeCommit is configured, and the recommended pre-receive hook is registered. All this is currently done by a script running on the GitLab machine, writing into the internal GitLab database, and on the file system. With #24189 (closed) we can get rid of part that writes directly in the DB.
With an API endpoint to register pre-receive hooks, we could move that script to a different machine, and use the API credentials for all the setup tasks (instead of API credentials for creating and configuring the repos, and SSH keys for the pre-receive hooks).
Intended users
Further details
I understand this is a "nice-to-have" kind of request, as there is the workaround with the SSH keys, but it would make our setup more elegant.
Proposal
The setup script calls the API to create the repository, calls the API to setup repository mirroring, and calls the new API endpoint to register the pre-receive hook (alternative since this is a common issue with repository mirroring: Make this an option in the API call to enable repository mirroring).
Permissions and Security
API keys (same as configuring other aspects of a repository)