debian-mirror-gitlab/app/models/concerns/deployment_platform.rb

36 lines
1.2 KiB
Ruby
Raw Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module DeploymentPlatform
2018-05-01 15:08:00 +05:30
# EE would override this and utilize environment argument
# rubocop:disable Gitlab/ModuleWithInstanceVariables
2018-03-27 19:54:05 +05:30
def deployment_platform(environment: nil)
2018-05-01 15:08:00 +05:30
@deployment_platform ||= {}
@deployment_platform[environment] ||= find_deployment_platform(environment)
2018-03-17 18:26:18 +05:30
end
private
2019-12-21 20:55:43 +05:30
def cluster_management_project_enabled?
2019-12-26 22:10:19 +05:30
Feature.enabled?(:cluster_management_project, self, default_enabled: true)
2019-12-21 20:55:43 +05:30
end
2018-05-01 15:08:00 +05:30
def find_deployment_platform(environment)
2019-09-30 21:07:59 +05:30
find_platform_kubernetes_with_cte(environment) ||
find_instance_cluster_platform_kubernetes(environment: environment)
2018-05-01 15:08:00 +05:30
end
# EE would override this and utilize environment argument
2019-09-30 21:07:59 +05:30
def find_platform_kubernetes_with_cte(_environment)
2019-12-21 20:55:43 +05:30
Clusters::ClustersHierarchy.new(self, include_management_project: cluster_management_project_enabled?).base_and_ancestors
2019-09-30 21:07:59 +05:30
.enabled.default_environment
2019-02-15 15:39:39 +05:30
.first&.platform_kubernetes
end
2019-07-31 22:56:46 +05:30
# 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-03-17 18:26:18 +05:30
end