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

update.rb « container_expiration_policies « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 37cf2fa6bf3a7fae23be9b94069b89ff74093847 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# frozen_string_literal: true

module Mutations
  module ContainerExpirationPolicies
    class Update < Mutations::BaseMutation
      include ResolvesProject

      graphql_name 'UpdateContainerExpirationPolicy'

      authorize :destroy_container_image

      argument :project_path,
               GraphQL::ID_TYPE,
               required: true,
               description: 'The project path where the container expiration policy is located.'

      argument :enabled,
               GraphQL::BOOLEAN_TYPE,
               required: false,
               description: copy_field_description(Types::ContainerExpirationPolicyType, :enabled)

      argument :cadence,
               Types::ContainerExpirationPolicyCadenceEnum,
               required: false,
               description: copy_field_description(Types::ContainerExpirationPolicyType, :cadence)

      argument :older_than,
               Types::ContainerExpirationPolicyOlderThanEnum,
               required: false,
               description: copy_field_description(Types::ContainerExpirationPolicyType, :older_than)

      argument :keep_n,
               Types::ContainerExpirationPolicyKeepEnum,
               required: false,
               description: copy_field_description(Types::ContainerExpirationPolicyType, :keep_n)

      argument :name_regex,
               Types::UntrustedRegexp,
               required: false,
               description: copy_field_description(Types::ContainerExpirationPolicyType, :name_regex)

      argument :name_regex_keep,
               Types::UntrustedRegexp,
               required: false,
               description: copy_field_description(Types::ContainerExpirationPolicyType, :name_regex_keep)

      field :container_expiration_policy,
            Types::ContainerExpirationPolicyType,
            null: true,
            description: 'The container expiration policy after mutation.'

      def resolve(project_path:, **args)
        project = authorized_find!(full_path: project_path)

        result = ::ContainerExpirationPolicies::UpdateService
          .new(container: project, current_user: current_user, params: args)
          .execute

        {
          container_expiration_policy: result.payload[:container_expiration_policy],
          errors: result.errors
        }
      end

      private

      def find_object(full_path:)
        resolve_project(full_path: full_path)
      end
    end
  end
end