diff options
author | James Fargher <proglottis@gmail.com> | 2019-04-10 14:13:43 +1200 |
---|---|---|
committer | James Fargher <proglottis@gmail.com> | 2019-05-07 08:37:03 +1200 |
commit | 733da6d6a015e8c951dcc02250cfe1fab87789c0 (patch) | |
tree | 6be40311a4753767d7219f2cff21c4eccbe18a5f /app/policies | |
parent | 863f2bcfb6ef7c6d3ce5726fa1a602e12f05ef57 (diff) | |
download | gitlab-ce-733da6d6a015e8c951dcc02250cfe1fab87789c0.tar.gz |
Instance level kubernetes clusters admin
Instance level clusters were already mostly supported, this change adds
admin area controllers for cluster CRUD
Diffstat (limited to 'app/policies')
-rw-r--r-- | app/policies/clusters/cluster_policy.rb | 1 | ||||
-rw-r--r-- | app/policies/clusters/instance_policy.rb | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/app/policies/clusters/cluster_policy.rb b/app/policies/clusters/cluster_policy.rb index d6d590687e2..316bd39f7a3 100644 --- a/app/policies/clusters/cluster_policy.rb +++ b/app/policies/clusters/cluster_policy.rb @@ -6,5 +6,6 @@ module Clusters delegate { cluster.group } delegate { cluster.project } + delegate { cluster.instance } end end diff --git a/app/policies/clusters/instance_policy.rb b/app/policies/clusters/instance_policy.rb new file mode 100644 index 00000000000..f72096e8fc6 --- /dev/null +++ b/app/policies/clusters/instance_policy.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Clusters + class InstancePolicy < BasePolicy + include ClusterableActions + + condition(:has_clusters, scope: :subject) { clusterable_has_clusters? } + condition(:can_have_multiple_clusters) { multiple_clusters_available? } + + rule { admin }.policy do + enable :read_cluster + enable :add_cluster + enable :create_cluster + enable :update_cluster + enable :admin_cluster + end + + rule { ~can_have_multiple_clusters & has_clusters }.prevent :add_cluster + end +end |