2020-12-04 13:09:55 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module Environments
|
|
|
|
module CanaryIngress
|
|
|
|
class Update < ::Mutations::BaseMutation
|
|
|
|
graphql_name 'EnvironmentsCanaryIngressUpdate'
|
|
|
|
|
|
|
|
authorize :update_environment
|
|
|
|
|
|
|
|
argument :id,
|
|
|
|
::Types::GlobalIDType[::Environment],
|
|
|
|
required: true,
|
2021-01-07 07:10:24 -05:00
|
|
|
description: 'The global ID of the environment to update.'
|
2020-12-04 13:09:55 -05:00
|
|
|
|
|
|
|
argument :weight,
|
|
|
|
GraphQL::INT_TYPE,
|
|
|
|
required: true,
|
2021-01-07 07:10:24 -05:00
|
|
|
description: 'The weight of the Canary Ingress.'
|
2020-12-04 13:09:55 -05:00
|
|
|
|
|
|
|
def resolve(id:, **kwargs)
|
|
|
|
environment = authorized_find!(id: id)
|
|
|
|
|
|
|
|
result = ::Environments::CanaryIngress::UpdateService
|
|
|
|
.new(environment.project, current_user, kwargs)
|
|
|
|
.execute_async(environment)
|
|
|
|
|
|
|
|
{ errors: Array.wrap(result[:message]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_object(id:)
|
|
|
|
# TODO: remove as part of https://gitlab.com/gitlab-org/gitlab/-/issues/257883
|
|
|
|
id = ::Types::GlobalIDType[::Environment].coerce_isolated_input(id)
|
|
|
|
GitlabSchema.find_by_gid(id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|