Refactor Services and Hooks
I wanted to create an integration for GitLab with an external service and noticed it was pretty hard to get started on this. I mean, in general the project service and its creation process is OK and doable, but more involved integrations are harder. (more on that later) Also, these integrations are not DRY and we could do better.
I also noticed there are 5 models which basicly do exactly the same thing!
- WebHook
- Service
- CI::WebHook
- CI::Service
- SystemHooks
I think we could merge these into one, and in the process solve a lot of other problems/annoyances too. We'd end up with only the Service model, which allows for scoping to support SystemHooks. The web hooks are just a service which does a post request, just as it does now. Also, all CI::XX will be merged. Those will get more DB fields, but I don't see a problem there.
Another problem which can be addressed is the creation of 22 services for each project. Hardly any project will ever need all of these, I don't have the data at hand, but I'm pretty sure this is just a waste and dirty. Extracting these to a ServiceTemplate model would remove the need for it, plus maybe a Admin wants to set default values or disable ALL services etc etc, which isn't possible in the current way the code behaves.
Advantages include, but are not limited to, a dry'er code base which, at least I expect will be easier to maintain and read as we can merge 5 models into one, and extract the templates to their own model. This will make it easier for anybody to integrate with us. For these integrations a new level is available, namespace level. (probably scoped to groups only?) which would allow for an integration like: new_member which triggers this member to be added to Slack. :)
P.S. I might be missing something on why there're distinctions between all these models apart from scoping and legacy code after the 8.0 release (the merge of CI).
P.S.S. This is a bit of a brain dump, if you're reading this and have a clear idea how to make it more structured, please do