diff options
author | Rémy Coutable <remy@rymai.me> | 2017-10-27 15:04:22 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-10-27 15:04:22 +0300 |
commit | 172ebcb8bb9c0b4d3c565560880fc604cae02b5e (patch) | |
tree | 7632d123a997458eb4d0d3e6dceb1e58901f643f /app | |
parent | fa3b4736604c8785ee5dba595f1f003751e15c59 (diff) | |
parent | 3aafcc16fbdde08bf333eab97c5b1b3c4249a5cf (diff) |
Merge branch 'ac-k8s-namespace-validator' into 'master'
Sanitize k8s default_namespace
Closes #38692
See merge request gitlab-org/gitlab-ce!15053
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project_services/kubernetes_service.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/models/project_services/kubernetes_service.rb b/app/models/project_services/kubernetes_service.rb index 8ba07173c74..5c0b3338a62 100644 --- a/app/models/project_services/kubernetes_service.rb +++ b/app/models/project_services/kubernetes_service.rb @@ -153,7 +153,10 @@ class KubernetesService < DeploymentService end def default_namespace - "#{project.path}-#{project.id}" if project.present? + return unless project + + slug = "#{project.path}-#{project.id}".downcase + slug.gsub(/[^-a-z0-9]/, '-').gsub(/^-+/, '') end def build_kubeclient!(api_path: 'api', api_version: 'v1') |