diff options
author | Matija Čupić <matteeyah@gmail.com> | 2017-11-18 22:18:42 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2017-11-18 23:04:13 +0300 |
commit | 1a9cef796275e6b9c95c1c381b6a31886f1dbb1d (patch) | |
tree | 4074db6d8c1cb6b8b1d2b8a6a29e8331a8bf7a12 /app/services/clusters/create_service.rb | |
parent | cc0c61155561e5baa1b28319ceb6633858a7d9f8 (diff) |
Limit projects to just one cluster
Diffstat (limited to 'app/services/clusters/create_service.rb')
-rw-r--r-- | app/services/clusters/create_service.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/services/clusters/create_service.rb b/app/services/clusters/create_service.rb index 1d407739b21..4519c94f91c 100644 --- a/app/services/clusters/create_service.rb +++ b/app/services/clusters/create_service.rb @@ -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 |