2020-05-20 18:08:00 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Admin
|
|
|
|
class PropagateIntegrationService
|
2020-09-08 15:08:41 +00:00
|
|
|
include PropagateService
|
2020-05-20 18:08:00 +00:00
|
|
|
|
|
|
|
def propagate
|
2020-10-07 00:08:24 +00:00
|
|
|
if integration.instance?
|
2020-10-23 18:08:31 +00:00
|
|
|
update_inherited_integrations
|
2020-11-12 03:09:17 +00:00
|
|
|
create_integration_for_groups_without_integration if Feature.enabled?(:group_level_integrations, default_enabled: true)
|
2020-10-07 00:08:24 +00:00
|
|
|
create_integration_for_projects_without_integration
|
|
|
|
else
|
2020-10-23 18:08:31 +00:00
|
|
|
update_inherited_descendant_integrations
|
2020-10-07 00:08:24 +00:00
|
|
|
create_integration_for_groups_without_integration_belonging_to_group
|
|
|
|
create_integration_for_projects_without_integration_belonging_to_group
|
|
|
|
end
|
2020-05-20 18:08:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-08-27 15:10:21 +00:00
|
|
|
def update_inherited_integrations
|
2020-10-23 18:08:31 +00:00
|
|
|
propagate_integrations(
|
|
|
|
Service.by_type(integration.type).inherit_from_id(integration.id),
|
|
|
|
PropagateIntegrationInheritWorker
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_inherited_descendant_integrations
|
|
|
|
propagate_integrations(
|
|
|
|
Service.inherited_descendants_from_self_or_ancestors_from(integration),
|
|
|
|
PropagateIntegrationInheritDescendantWorker
|
|
|
|
)
|
2020-05-20 18:08:00 +00:00
|
|
|
end
|
|
|
|
|
2020-09-15 15:10:08 +00:00
|
|
|
def create_integration_for_groups_without_integration
|
2020-10-23 18:08:31 +00:00
|
|
|
propagate_integrations(
|
|
|
|
Group.without_integration(integration),
|
|
|
|
PropagateIntegrationGroupWorker
|
|
|
|
)
|
2020-09-15 15:10:08 +00:00
|
|
|
end
|
2020-10-07 00:08:24 +00:00
|
|
|
|
|
|
|
def create_integration_for_groups_without_integration_belonging_to_group
|
2020-10-23 18:08:31 +00:00
|
|
|
propagate_integrations(
|
|
|
|
integration.group.descendants.without_integration(integration),
|
|
|
|
PropagateIntegrationGroupWorker
|
|
|
|
)
|
2020-10-07 00:08:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create_integration_for_projects_without_integration_belonging_to_group
|
2020-10-23 18:08:31 +00:00
|
|
|
propagate_integrations(
|
|
|
|
Project.without_integration(integration).in_namespace(integration.group.self_and_descendants),
|
|
|
|
PropagateIntegrationProjectWorker
|
|
|
|
)
|
2020-10-07 00:08:24 +00:00
|
|
|
end
|
2020-05-20 18:08:00 +00:00
|
|
|
end
|
|
|
|
end
|