From 914ea32e0efca21436220df2c10e1bfbe4ed3da9 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 16 Oct 2019 09:07:51 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/services/ci/pipeline_trigger_service.rb | 29 +++++++++++++++++++++++++---- app/services/groups/transfer_service.rb | 8 +++++++- app/services/groups/update_service.rb | 16 ++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) (limited to 'app/services') diff --git a/app/services/ci/pipeline_trigger_service.rb b/app/services/ci/pipeline_trigger_service.rb index 0e99f142492..37b9b4c362c 100644 --- a/app/services/ci/pipeline_trigger_service.rb +++ b/app/services/ci/pipeline_trigger_service.rb @@ -38,11 +38,34 @@ module Ci end def create_pipeline_from_job(job) - # overridden in EE + # this check is to not leak the presence of the project if user cannot read it + return unless can?(job.user, :read_project, project) + + return error("400 Job has to be running", 400) unless job.running? + + pipeline = Ci::CreatePipelineService.new(project, job.user, ref: params[:ref]) + .execute(:pipeline, ignore_skip_ci: true) do |pipeline| + source = job.sourced_pipelines.build( + source_pipeline: job.pipeline, + source_project: job.project, + pipeline: pipeline, + project: project) + + pipeline.source_pipeline = source + pipeline.variables.build(variables) + end + + if pipeline.persisted? + success(pipeline: pipeline) + else + error(pipeline.errors.messages, 400) + end end def job_from_token - # overridden in EE + strong_memoize(:job) do + Ci::Build.find_by_token(params[:token].to_s) + end end def variables @@ -52,5 +75,3 @@ module Ci end end end - -Ci::PipelineTriggerService.prepend_if_ee('EE::Ci::PipelineTriggerService') diff --git a/app/services/groups/transfer_service.rb b/app/services/groups/transfer_service.rb index fe7e07ef9f0..6902b7bd529 100644 --- a/app/services/groups/transfer_service.rb +++ b/app/services/groups/transfer_service.rb @@ -7,7 +7,8 @@ module Groups namespace_with_same_path: s_('TransferGroup|The parent group already has a subgroup with the same path.'), group_is_already_root: s_('TransferGroup|Group is already a root group.'), same_parent_as_current: s_('TransferGroup|Group is already associated to the parent group.'), - invalid_policies: s_("TransferGroup|You don't have enough permissions.") + invalid_policies: s_("TransferGroup|You don't have enough permissions."), + group_contains_images: s_('TransferGroup|Cannot update the path because there are projects under this group that contain Docker images in their Container Registry. Please remove the images from your projects first and try again.') }.freeze TransferError = Class.new(StandardError) @@ -46,6 +47,7 @@ module Groups raise_transfer_error(:same_parent_as_current) if same_parent? raise_transfer_error(:invalid_policies) unless valid_policies? raise_transfer_error(:namespace_with_same_path) if namespace_with_same_path? + raise_transfer_error(:group_contains_images) if group_projects_contain_registry_images? end def group_is_already_root? @@ -72,6 +74,10 @@ module Groups end # rubocop: enable CodeReuse/ActiveRecord + def group_projects_contain_registry_images? + @group.has_container_repositories? + end + def update_group_attributes if @new_parent_group && @new_parent_group.visibility_level < @group.visibility_level update_children_and_projects_visibility diff --git a/app/services/groups/update_service.rb b/app/services/groups/update_service.rb index 534de601e20..be7502a193e 100644 --- a/app/services/groups/update_service.rb +++ b/app/services/groups/update_service.rb @@ -8,6 +8,11 @@ module Groups reject_parent_id! remove_unallowed_params + if renaming_group_with_container_registry_images? + group.errors.add(:base, container_images_error) + return false + end + return false unless valid_visibility_level_change?(group, params[:visibility_level]) return false unless valid_share_with_group_lock_change? @@ -35,6 +40,17 @@ module Groups # overridden in EE end + def renaming_group_with_container_registry_images? + new_path = params[:path] + + new_path && new_path != group.path && + group.has_container_repositories? + end + + def container_images_error + s_("GroupSettings|Cannot update the path because there are projects under this group that contain Docker images in their Container Registry. Please remove the images from your projects first and try again.") + end + def after_update if group.previous_changes.include?(:visibility_level) && group.private? # don't enqueue immediately to prevent todos removal in case of a mistake -- cgit v1.2.3