The current approach requires catching exceptions to handle these errors
and callers are already handling model validations so it seems more
appropriate. Also it seemed to convoluted to add this logic directly to
the model since the model needs to check too many possible associations
to determine whether or not there are more than one cluster since the
model doesn't know what it's being created on. Additionally we only
wanted to validate during create to avoid the risk of existing models
becoming invalid by many different edge cases.
Include a new policy in Clusterables
(projects and groups), which checks if another cluster
can be added
clusterable_has_cluster? and multiple_clusters_available
private methods will be overriden in EE
Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/34758
To reduce the number of abstract methods, use polymorphic_paths for
collection routes. Unfortunately for member routes, polymorphic_paths
does not support namespaced classes, so still continue to override
methods.
- Move show path for cluster to ClusterPresenter
- Create ClusterablePresenter to encapsulate logic. Consolidates
scattered methods from BaseController and ClustersHelper into an object.