提交 db9783f7 编写于 作者: S Stan Hu

Merge branch 'refactor_deployment_cluster' into 'master'

Refactor Deployment#cluster to #deployment_platform_cluster

See merge request gitlab-org/gitlab-ce!29961
......@@ -84,12 +84,9 @@ class Deployment < ApplicationRecord
Commit.truncate_sha(sha)
end
def cluster
platform = project.deployment_platform(environment: environment.name)
if platform.present? && platform.respond_to?(:cluster)
platform.cluster
end
# Deprecated - will be replaced by a persisted cluster_id
def deployment_platform_cluster
environment.deployment_platform&.cluster
end
def execute_hooks
......
......@@ -20,7 +20,7 @@ module Gitlab
private
def deployment_cluster
build.deployment&.cluster
build.deployment&.deployment_platform_cluster
end
def kubernetes_namespace
......
......@@ -23,7 +23,7 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
let(:cluster) { create(:cluster, :group) }
before do
allow(build.deployment).to receive(:cluster).and_return(cluster)
allow(build.deployment).to receive(:deployment_platform_cluster).and_return(cluster)
end
it { is_expected.to be_truthy }
......@@ -49,7 +49,7 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
context 'and no cluster to deploy to' do
before do
expect(deployment.cluster).to be_nil
expect(deployment.deployment_platform_cluster).to be_nil
end
it { is_expected.to be_falsey }
......@@ -67,7 +67,7 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
let(:cluster) { create(:cluster, :group) }
before do
allow(build.deployment).to receive(:cluster).and_return(cluster)
allow(build.deployment).to receive(:deployment_platform_cluster).and_return(cluster)
end
it 'creates a kubernetes namespace' do
......@@ -84,7 +84,7 @@ describe Gitlab::Ci::Build::Prerequisite::KubernetesNamespace do
context 'completion is not required' do
before do
expect(deployment.cluster).to be_nil
expect(deployment.deployment_platform_cluster).to be_nil
end
it 'does not create a namespace' do
......
......@@ -380,12 +380,12 @@ describe Deployment do
end
end
describe '#cluster' do
describe '#deployment_platform_cluster' do
let(:deployment) { create(:deployment) }
let(:project) { deployment.project }
let(:environment) { deployment.environment }
subject { deployment.cluster }
subject { deployment.deployment_platform_cluster }
before do
expect(project).to receive(:deployment_platform)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册