2018-08-03 17:22:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-04 22:35:41 +00:00
|
|
|
module DeploymentPlatform
|
2018-03-21 14:59:40 +00:00
|
|
|
# EE would override this and utilize environment argument
|
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)
|
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-08 06:03:09 +00:00
|
|
|
find_platform_kubernetes(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
|
|
|
|
|
2019-07-08 06:03:09 +00:00
|
|
|
def find_platform_kubernetes(environment)
|
|
|
|
if Feature.enabled?(:clusters_cte)
|
|
|
|
find_platform_kubernetes_with_cte(environment)
|
|
|
|
else
|
|
|
|
find_cluster_platform_kubernetes(environment: environment) ||
|
|
|
|
find_group_cluster_platform_kubernetes(environment: environment)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# EE would override this and utilize environment argument
|
|
|
|
def find_platform_kubernetes_with_cte(_environment)
|
|
|
|
Clusters::ClustersHierarchy.new(self).base_and_ancestors
|
|
|
|
.enabled.default_environment
|
|
|
|
.first&.platform_kubernetes
|
|
|
|
end
|
|
|
|
|
2018-03-21 14:59:40 +00:00
|
|
|
# EE would override this and utilize environment argument
|
|
|
|
def find_cluster_platform_kubernetes(environment: nil)
|
|
|
|
clusters.enabled.default_environment
|
|
|
|
.last&.platform_kubernetes
|
2018-01-04 22:35:41 +00:00
|
|
|
end
|
|
|
|
|
2018-10-29 02:28:36 +00:00
|
|
|
# EE would override this and utilize environment argument
|
|
|
|
def find_group_cluster_platform_kubernetes(environment: nil)
|
2018-12-02 21:22:33 +00:00
|
|
|
Clusters::Cluster.enabled.default_environment.ancestor_clusters_for_clusterable(self)
|
|
|
|
.first&.platform_kubernetes
|
2018-10-29 02:28:36 +00:00
|
|
|
end
|
|
|
|
|
2019-04-18 02:45:31 +00: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 22:35:41 +00:00
|
|
|
end
|