Commit 1fc33b5d authored by Kamil Trzciński's avatar Kamil Trzciński

Fix deployment_platform not memoizing values in correct way

parent 4e2644ce
module DeploymentPlatform
# EE would override this and utilize environment argument
def deployment_platform(environment: nil)
@deployment_platform ||=
@deployment_platform ||= {}
@deployment_platform[environment] ||= begin
find_cluster_platform_kubernetes(environment: environment) ||
find_kubernetes_service_integration ||
build_cluster_and_deployment_platform
end
end
private
# EE would override this and utilize environment argument
def find_cluster_platform_kubernetes(environment: nil)
clusters.enabled.default_environment
.last&.platform_kubernetes
end
private
def find_kubernetes_service_integration
services.deployment.reorder(nil).find_by(active: true)
end
......
......@@ -2,15 +2,6 @@ module EE
module DeploymentPlatform
extend ::Gitlab::Utils::Override
override :deployment_platform
def deployment_platform(environment: nil)
find_cluster_platform_kubernetes(environment: environment) ||
find_kubernetes_service_integration ||
build_cluster_and_deployment_platform
end
private
override :find_cluster_platform_kubernetes
def find_cluster_platform_kubernetes(environment: nil)
return super unless environment && feature_available?(:multiple_clusters)
......
......@@ -378,7 +378,7 @@ describe Environment do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
it 'returns the terminals from the deployment service' do
expect(project.deployment_platform)
expect(project.deployment_platform(environment: environment))
.to receive(:terminals).with(environment)
.and_return(:fake_terminals)
......@@ -419,7 +419,7 @@ describe Environment do
end
it 'returns the rollout status from the deployment service' do
expect(project.deployment_platform)
expect(project.deployment_platform(environment: environment))
.to receive(:rollout_status).with(environment)
.and_return(:fake_rollout_status)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment