debian-mirror-gitlab/app/graphql/mutations/container_expiration_policies/update.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
2.3 KiB
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
module Mutations
module ContainerExpirationPolicies
class Update < Mutations::BaseMutation
graphql_name 'UpdateContainerExpirationPolicy'
2022-04-04 11:22:00 +05:30
include FindsProject
2020-06-23 00:09:42 +05:30
authorize :destroy_container_image
argument :project_path,
2021-10-27 15:23:28 +05:30
GraphQL::Types::ID,
2020-06-23 00:09:42 +05:30
required: true,
2021-10-27 15:23:28 +05:30
description: 'Project path where the container expiration policy is located.'
2020-06-23 00:09:42 +05:30
argument :enabled,
2021-10-27 15:23:28 +05:30
GraphQL::Types::Boolean,
2020-06-23 00:09:42 +05:30
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)
2020-07-28 23:09:34 +05:30
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)
2020-06-23 00:09:42 +05:30
field :container_expiration_policy,
Types::ContainerExpirationPolicyType,
null: true,
2021-10-27 15:23:28 +05:30
description: 'Container expiration policy after mutation.'
2020-06-23 00:09:42 +05:30
def resolve(project_path:, **args)
2021-03-11 19:13:27 +05:30
project = authorized_find!(project_path)
2020-06-23 00:09:42 +05:30
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
end
end
end