diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/graphql/mutations/container_expiration_policies/update.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/graphql/mutations/container_expiration_policies/update.rb')
-rw-r--r-- | app/graphql/mutations/container_expiration_policies/update.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/app/graphql/mutations/container_expiration_policies/update.rb b/app/graphql/mutations/container_expiration_policies/update.rb new file mode 100644 index 00000000000..c210571c6ca --- /dev/null +++ b/app/graphql/mutations/container_expiration_policies/update.rb @@ -0,0 +1,62 @@ +# 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) + + 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 |