Limit projects to just one cluster

This commit is contained in:
Matija Čupić 2017-11-18 20:18:42 +01:00
parent cc0c611555
commit 1a9cef7962
No known key found for this signature in database
GPG key ID: 4BAF84FFACD2E5DE

View file

@ -5,6 +5,8 @@ module Clusters
def execute(access_token)
@access_token = access_token
return unless can_create_cluster?
create_cluster.tap do |cluster|
ClusterProvisionWorker.perform_async(cluster.id) if cluster.persisted?
end
@ -25,5 +27,13 @@ module Clusters
@cluster_params = params.merge(user: current_user, projects: [project])
end
def can_create_cluster?
if project.clusters.empty?
true
else
false
end
end
end
end