2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Clusters
|
2018-12-13 13:39:08 +05:30
|
|
|
class UpdateService
|
|
|
|
attr_reader :current_user, :params
|
|
|
|
|
|
|
|
def initialize(user = nil, params = {})
|
|
|
|
@current_user, @params = user, params.dup
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def execute(cluster)
|
2019-12-26 22:10:19 +05:30
|
|
|
if validate_params(cluster)
|
|
|
|
cluster.update(params)
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def validate_params(cluster)
|
2020-04-22 19:07:51 +05:30
|
|
|
::Clusters::Management::ValidateManagementProjectPermissionsService.new(current_user)
|
|
|
|
.execute(cluster, params[:management_project_id])
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|