Welcome to mirror list, hosted at ThFree Co, Russian Federation.

destroy.rb « pipeline « ci « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 935cf45c4ab7fe606c0d188826d561f45f72416a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

module Mutations
  module Ci
    module Pipeline
      class Destroy < Base
        graphql_name 'PipelineDestroy'

        authorize :destroy_pipeline

        def resolve(id:)
          pipeline = authorized_find!(id: id)
          project = pipeline.project

          return undergoing_refresh_error(project) if project.refreshing_build_artifacts_size?

          result = ::Ci::DestroyPipelineService.new(project, current_user).execute(pipeline)
          {
            success: result.success?,
            errors: result.errors
          }
        end

        private

        def undergoing_refresh_error(project)
          Gitlab::ProjectStatsRefreshConflictsLogger.warn_request_rejected_during_stats_refresh(project.id)

          {
            success: false,
            errors: ['Action temporarily disabled. The project this pipeline belongs to is undergoing stats refresh.']
          }
        end
      end
    end
  end
end