2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-03 17:24:32 -04:00
|
|
|
class ClusterProvisionWorker
|
2017-11-28 11:08:30 -05:00
|
|
|
include ApplicationWorker
|
2017-10-03 13:33:37 -04:00
|
|
|
include ClusterQueue
|
2017-09-30 11:54:22 -04:00
|
|
|
|
2019-10-30 11:14:17 -04:00
|
|
|
worker_has_external_dependencies!
|
|
|
|
|
2017-09-30 11:54:22 -04:00
|
|
|
def perform(cluster_id)
|
2017-10-13 13:21:23 -04:00
|
|
|
Clusters::Cluster.find_by_id(cluster_id).try do |cluster|
|
2017-10-30 11:18:15 -04:00
|
|
|
cluster.provider.try do |provider|
|
2019-10-31 23:06:26 -04:00
|
|
|
if cluster.gcp?
|
|
|
|
Clusters::Gcp::ProvisionService.new.execute(provider)
|
|
|
|
elsif cluster.aws?
|
|
|
|
Clusters::Aws::ProvisionService.new.execute(provider)
|
|
|
|
end
|
2017-10-13 13:21:23 -04:00
|
|
|
end
|
2017-09-30 11:54:22 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|