summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2018-03-21 08:59:40 -0600
committerMayra Cabrera <mcabrera@gitlab.com>2018-03-22 14:52:33 -0600
commitca59bfdc6657fc20a27e93f41fc9e38c41498389 (patch)
treefb1a7397b1940445dc7c41ba8133027df2812258 /app
parentfbb83069deaad3db1239af66e6c9dc913f29f8f8 (diff)
downloadgitlab-ce-ca59bfdc6657fc20a27e93f41fc9e38c41498389.tar.gz
Rearrange DeploymentPlatform methods
- Change find_cluster_platform_kubernetes to ignore environment argument - Fix broken specs CE Port of: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/5047/
Diffstat (limited to 'app')
-rw-r--r--app/models/clusters/cluster.rb2
-rw-r--r--app/models/concerns/deployment_platform.rb10
2 files changed, 8 insertions, 4 deletions
diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb
index 49eb069016a..bfdfc5ae6fe 100644
--- a/app/models/clusters/cluster.rb
+++ b/app/models/clusters/cluster.rb
@@ -10,6 +10,7 @@ module Clusters
Applications::Prometheus.application_name => Applications::Prometheus,
Applications::Runner.application_name => Applications::Runner
}.freeze
+ DEFAULT_ENVIRONMENT = '*'.freeze
belongs_to :user
@@ -50,6 +51,7 @@ module Clusters
scope :enabled, -> { where(enabled: true) }
scope :disabled, -> { where(enabled: false) }
+ scope :default_environment, -> { where(environment_scope: DEFAULT_ENVIRONMENT) }
def status_name
if provider
diff --git a/app/models/concerns/deployment_platform.rb b/app/models/concerns/deployment_platform.rb
index faa94204e33..6ddfc7b0d7b 100644
--- a/app/models/concerns/deployment_platform.rb
+++ b/app/models/concerns/deployment_platform.rb
@@ -1,16 +1,18 @@
module DeploymentPlatform
- # EE would override this and utilize the extra argument
+ # EE would override this and utilize environment argument
def deployment_platform(environment: nil)
@deployment_platform ||=
- find_cluster_platform_kubernetes ||
+ find_cluster_platform_kubernetes(environment: environment) ||
find_kubernetes_service_integration ||
build_cluster_and_deployment_platform
end
private
- def find_cluster_platform_kubernetes
- clusters.find_by(enabled: true)&.platform_kubernetes
+ # EE would override this and utilize environment argument
+ def find_cluster_platform_kubernetes(environment: nil)
+ clusters.enabled.default_environment
+ .last&.platform_kubernetes
end
def find_kubernetes_service_integration