2018-08-03 13:22:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-04 17:35:41 -05:00
|
|
|
module DeploymentPlatform
|
2018-03-21 10:59:40 -04:00
|
|
|
# EE would override this and utilize environment argument
|
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
|
|
|
|
|
2019-10-14 08:06:14 -04:00
|
|
|
def cluster_management_project_enabled?
|
2019-11-18 01:06:20 -05:00
|
|
|
Feature.enabled?(:cluster_management_project, self, default_enabled: true)
|
2019-10-14 08:06:14 -04:00
|
|
|
end
|
|
|
|
|
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
|
|
|
|
|
2019-07-08 02:03:09 -04:00
|
|
|
# EE would override this and utilize environment argument
|
|
|
|
def find_platform_kubernetes_with_cte(_environment)
|
2019-10-14 08:06:14 -04:00
|
|
|
Clusters::ClustersHierarchy.new(self, include_management_project: cluster_management_project_enabled?).base_and_ancestors
|
2019-07-08 02:03:09 -04:00
|
|
|
.enabled.default_environment
|
|
|
|
.first&.platform_kubernetes
|
|
|
|
end
|
|
|
|
|
2019-04-17 22:45:31 -04:00
|
|
|
# EE would override this and utilize environment argument
|
|
|
|
def find_instance_cluster_platform_kubernetes(environment: nil)
|
|
|
|
Clusters::Instance.new.clusters.enabled.default_environment
|
|
|
|
.first&.platform_kubernetes
|
|
|
|
end
|
2018-01-04 17:35:41 -05:00
|
|
|
end
|