summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-03-27 08:27:32 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-03-27 08:27:32 +0000
commitffa73498b1c3125eec6d51db4502ab22da664773 (patch)
tree4ba735d69e12408735d855ebfcc57fb0365ae7d2 /app/models
parent835fe4d324b5a89c09f06d74d5ddc73a2c41a38b (diff)
parent1a79beff6ea15c8ce37bc461103d6a5f46ff2955 (diff)
downloadgitlab-ce-ffa73498b1c3125eec6d51db4502ab22da664773.tar.gz
Merge branch '5347-fix-multiple-clusters-incorrect-details-injected' into 'master'
Port to CE: Resolve "Multiple clusters: incorrect cluster details injected - environment scope is ignored" See merge request gitlab-org/gitlab-ce!17904
Diffstat (limited to 'app/models')
-rw-r--r--app/models/clusters/cluster.rb2
-rw-r--r--app/models/concerns/deployment_platform.rb22
2 files changed, 17 insertions, 7 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..52851b3d0b2 100644
--- a/app/models/concerns/deployment_platform.rb
+++ b/app/models/concerns/deployment_platform.rb
@@ -1,16 +1,24 @@
module DeploymentPlatform
- # EE would override this and utilize the extra argument
+ # EE would override this and utilize environment argument
+ # rubocop:disable Gitlab/ModuleWithInstanceVariables
def deployment_platform(environment: nil)
- @deployment_platform ||=
- find_cluster_platform_kubernetes ||
- find_kubernetes_service_integration ||
- build_cluster_and_deployment_platform
+ @deployment_platform ||= {}
+
+ @deployment_platform[environment] ||= find_deployment_platform(environment)
end
private
- def find_cluster_platform_kubernetes
- clusters.find_by(enabled: true)&.platform_kubernetes
+ def find_deployment_platform(environment)
+ find_cluster_platform_kubernetes(environment: environment) ||
+ find_kubernetes_service_integration ||
+ build_cluster_and_deployment_platform
+ end
+
+ # 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