summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2019-06-24 13:46:21 +1200
committerThong Kuah <tkuah@gitlab.com>2019-06-24 16:59:22 +1200
commitee18ca2fa590453b42c7cba28c334d1327aa8b33 (patch)
tree8bc2d3bd19b47e33721712825aed8f61d02703bb
parent25adee56f76ec6e0faca1dc4d7fef36e88c19f3d (diff)
downloadgitlab-ce-ee18ca2fa590453b42c7cba28c334d1327aa8b33.tar.gz
Rename method to not clash with #clusterrefactor_deployment_cluster
We will introduce #cluster at a later stage. Also deprecate this method
-rw-r--r--app/models/deployment.rb3
-rw-r--r--lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb2
-rw-r--r--spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb8
-rw-r--r--spec/models/deployment_spec.rb4
4 files changed, 9 insertions, 8 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index 23cc3f00527..e0648746e31 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -84,7 +84,8 @@ class Deployment < ApplicationRecord
Commit.truncate_sha(sha)
end
- def cluster
+ # Deprecated - will be replaced by a persisted cluster_id
+ def deployment_platform_cluster
environment.deployment_platform&.cluster
end
diff --git a/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb b/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb
index 531c9ce4256..472492b6bfa 100644
--- a/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb
+++ b/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb
@@ -21,7 +21,7 @@ module Gitlab
private
def deployment_cluster
- build.deployment&.cluster
+ build.deployment&.deployment_platform_cluster
end
def kubernetes_namespace
diff --git a/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb b/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb
index 5ac5122e800..5da414dd629 100644
--- a/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb
+++ b/spec/lib/gitlab/ci/build/prerequisite/kubernetes_namespace_spec.rb
@@ -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 }
@@ -55,7 +55,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 }
@@ -73,7 +73,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
@@ -90,7 +90,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
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb
index 1dceef3fc00..a433878f3bc 100644
--- a/spec/models/deployment_spec.rb
+++ b/spec/models/deployment_spec.rb
@@ -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)