Create a POST endpoint for system hooks to inspect new private projects
When we enable new private projects, we want to ensure that projects created are forks associated with a repository and not bare repositories with code unrelated to Eclipse projects. To that end, we will want to accept system hook events to receive project_create
events and inspect the created project.
Once we receive a system hook call, we need to verify the event type and then cast the data to the proper request type. This is required as Gitlab does not allow for scoping which system events can or cannot create webhook calls. An additional note is that the endpoint should reflect this and be a generic path, such as /git/webhooks/gitlab/system
. This hook should trigger a queued event in an executor as we don't want to block the request while we validate the data (the hook doesn't accept responses, so we don't want to lock up system resources for no reason).
As the project creation event does not include information about whether a project is a fork, we will have to callback to Gitlab to read this information. We should consider using a Gitlab lib like Gitlab4J to simplify some of the writing of code and reduce maintenance costs. We should then inspect the data that we get back about the new project, and check if we should delete.
Conditions for deletion:
- Project is private
- Project is in a users namespace
- Project has no forked from/parent repo data
@mbarbero are there any other conditions we want to observe for deleting private projects? I think this covers what we will need for the MBO.