2017-09-28 05:11:17 -04:00
|
|
|
module Ci
|
|
|
|
class CreateClusterService < BaseService
|
2017-09-30 11:54:22 -04:00
|
|
|
def execute(access_token)
|
2017-10-03 10:44:06 -04:00
|
|
|
params['gcp_machine_type'] ||= GoogleApi::CloudPlatform::Client::DEFAULT_MACHINE_TYPE
|
2017-10-01 04:48:21 -04:00
|
|
|
|
2017-10-02 08:58:50 -04:00
|
|
|
project.create_cluster(
|
2017-09-30 11:54:22 -04:00
|
|
|
params.merge(user: current_user,
|
2017-10-02 08:58:50 -04:00
|
|
|
status: Gcp::Cluster.statuses[:scheduled],
|
2017-10-03 10:44:06 -04:00
|
|
|
gcp_token: access_token)).tap do |cluster|
|
|
|
|
ClusterCreationWorker.perform_async(cluster.id) if cluster.persisted?
|
|
|
|
end
|
2017-09-28 05:11:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|