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