2018-08-03 17:22:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-04 22:35:41 +00:00
|
|
|
module DeploymentPlatform
|
2018-03-26 22:14:23 +00:00
|
|
|
# rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2018-03-07 10:14:25 +00:00
|
|
|
def deployment_platform(environment: nil)
|
2022-05-05 09:08:00 +00:00
|
|
|
return unless self.namespace.certificate_based_clusters_enabled?
|
2022-02-23 18:16:59 +00:00
|
|
|
|
2018-03-26 22:14:23 +00:00
|
|
|
@deployment_platform ||= {}
|
|
|
|
|
|
|
|
@deployment_platform[environment] ||= find_deployment_platform(environment)
|
2018-01-04 22:35:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-03-26 22:14:23 +00:00
|
|
|
def find_deployment_platform(environment)
|
2019-07-16 23:37:34 +00:00
|
|
|
find_platform_kubernetes_with_cte(environment) ||
|
2019-06-27 12:29:19 +00:00
|
|
|
find_instance_cluster_platform_kubernetes(environment: environment)
|
2018-03-26 22:14:23 +00:00
|
|
|
end
|
|
|
|
|
2020-07-08 12:09:33 +00:00
|
|
|
def find_platform_kubernetes_with_cte(environment)
|
|
|
|
if environment
|
2021-06-02 00:09:56 +00:00
|
|
|
::Clusters::ClustersHierarchy.new(self)
|
2020-07-08 12:09:33 +00:00
|
|
|
.base_and_ancestors
|
|
|
|
.enabled
|
|
|
|
.on_environment(environment, relevant_only: true)
|
|
|
|
.first&.platform_kubernetes
|
|
|
|
else
|
2021-06-02 00:09:56 +00:00
|
|
|
Clusters::ClustersHierarchy.new(self).base_and_ancestors
|
2019-07-08 06:03:09 +00:00
|
|
|
.enabled.default_environment
|
|
|
|
.first&.platform_kubernetes
|
2020-07-08 12:09:33 +00:00
|
|
|
end
|
2019-07-08 06:03:09 +00:00
|
|
|
end
|
|
|
|
|
2019-04-18 02:45:31 +00:00
|
|
|
def find_instance_cluster_platform_kubernetes(environment: nil)
|
2020-07-08 12:09:33 +00:00
|
|
|
if environment
|
|
|
|
::Clusters::Instance.new.clusters.enabled.on_environment(environment, relevant_only: true)
|
2019-04-18 02:45:31 +00:00
|
|
|
.first&.platform_kubernetes
|
2020-07-08 12:09:33 +00:00
|
|
|
else
|
|
|
|
Clusters::Instance.new.clusters.enabled.default_environment
|
|
|
|
.first&.platform_kubernetes
|
|
|
|
end
|
2019-04-18 02:45:31 +00:00
|
|
|
end
|
2018-01-04 22:35:41 +00:00
|
|
|
end
|