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

remove_project.rb « job_token_scope « ci « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 71c9083bef802e7fde44cc6a70c1a2f5a7d89892 (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
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true

module Mutations
  module Ci
    module JobTokenScope
      class RemoveProject < BaseMutation
        include FindsProject

        graphql_name 'CiJobTokenScopeRemoveProject'

        authorize :admin_project

        argument :project_path, GraphQL::ID_TYPE,
                 required: true,
                 description: 'The project that the CI job token scope belongs to.'

        argument :target_project_path, GraphQL::ID_TYPE,
                 required: true,
                 description: 'The project to be removed from the CI job token scope.'

        field :ci_job_token_scope,
          Types::Ci::JobTokenScopeType,
          null: true,
          description: "The CI job token's scope of access."

        def resolve(project_path:, target_project_path:)
          project = authorized_find!(project_path)
          target_project = Project.find_by_full_path(target_project_path)

          result = ::Ci::JobTokenScope::RemoveProjectService
            .new(project, current_user)
            .execute(target_project)

          if result.success?
            {
              ci_job_token_scope: ::Ci::JobToken::Scope.new(project),
              errors: []
            }
          else
            {
              ci_job_token_scope: nil,
              errors: [result.message]
            }
          end
        end
      end
    end
  end
end