summaryrefslogtreecommitdiff
path: root/app/models/clusters/cluster.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 12:07:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-12 12:07:33 +0000
commit784fae4b9d7e92350075df2a43d06893080ed1e6 (patch)
treec7a6fd444acd6897622b233b250a34fd176f01da /app/models/clusters/cluster.rb
parentfc53ce8e6ca67bf217470179a1ea6cf139bcffad (diff)
downloadgitlab-ce-784fae4b9d7e92350075df2a43d06893080ed1e6.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/clusters/cluster.rb')
-rw-r--r--app/models/clusters/cluster.rb30
1 files changed, 22 insertions, 8 deletions
diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb
index 0cb18ba90c0..3742bbd8446 100644
--- a/app/models/clusters/cluster.rb
+++ b/app/models/clusters/cluster.rb
@@ -249,14 +249,9 @@ module Clusters
end
def kubernetes_namespace_for(environment)
- project = environment.project
- persisted_namespace = Clusters::KubernetesNamespaceFinder.new(
- self,
- project: project,
- environment_name: environment.name
- ).execute
-
- persisted_namespace&.namespace || Gitlab::Kubernetes::DefaultNamespace.new(self, project: project).from_environment_slug(environment.slug)
+ managed_namespace(environment) ||
+ ci_configured_namespace(environment) ||
+ default_namespace(environment)
end
def allow_user_defined_namespace?
@@ -308,6 +303,25 @@ module Clusters
end
end
+ def managed_namespace(environment)
+ Clusters::KubernetesNamespaceFinder.new(
+ self,
+ project: environment.project,
+ environment_name: environment.name
+ ).execute&.namespace
+ end
+
+ def ci_configured_namespace(environment)
+ environment.last_deployable&.expanded_kubernetes_namespace
+ end
+
+ def default_namespace(environment)
+ Gitlab::Kubernetes::DefaultNamespace.new(
+ self,
+ project: environment.project
+ ).from_environment_slug(environment.slug)
+ end
+
def instance_domain
@instance_domain ||= Gitlab::CurrentSettings.auto_devops_domain
end