Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-12-04 00:00:25 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2017-12-04 00:00:25 +0300
commitf1cce0cba88089442194b53833b6b5a0ca96e8e4 (patch)
treea62185a58ff201741dbfee7f7914f1ffe038b60c /app/finders
parent5ea53d2e8179e3a1e3d4b991a91d506ce13c3fca (diff)
parent363c57468dc6f656c6c345f0b9eda32029571201 (diff)
Merge remote-tracking branch 'origin/list-multiple-clusters' into cluster-page-with-list-clusters
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/clusters_finder.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/finders/clusters_finder.rb b/app/finders/clusters_finder.rb
new file mode 100644
index 00000000000..c13f98257bf
--- /dev/null
+++ b/app/finders/clusters_finder.rb
@@ -0,0 +1,29 @@
+class ClustersFinder
+ def initialize(project, user, scope)
+ @project = project
+ @user = user
+ @scope = scope || :active
+ end
+
+ def execute
+ clusters = project.clusters
+ filter_by_scope(clusters)
+ end
+
+ private
+
+ attr_reader :project, :user, :scope
+
+ def filter_by_scope(clusters)
+ case scope.to_sym
+ when :all
+ clusters
+ when :inactive
+ clusters.disabled
+ when :active
+ clusters.enabled
+ else
+ raise "Invalid scope #{scope}"
+ end
+ end
+end