Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2018-10-16 23:03:59 +0300
committerMayra Cabrera <mcabrera@gitlab.com>2018-10-22 17:54:00 +0300
commite3ca493876ab71ed29817a0af436fc563f564bbe (patch)
treebca9826ae1cc1b8140249e570626f22eb48cb960 /lib/gitlab/namespace_sanitizer.rb
parenta310a638db037d3914cf12e580c7a41209d2d06e (diff)
Add Clusters::KubernetesNamespace model
This model will be used to persist into database Kubernetes properties, such as namespace, service account name and service account token.
Diffstat (limited to 'lib/gitlab/namespace_sanitizer.rb')
-rw-r--r--lib/gitlab/namespace_sanitizer.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/gitlab/namespace_sanitizer.rb b/lib/gitlab/namespace_sanitizer.rb
new file mode 100644
index 00000000000..d755bbbcaf9
--- /dev/null
+++ b/lib/gitlab/namespace_sanitizer.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module Gitlab
+ class NamespaceSanitizer
+ def self.sanitize(namespace)
+ namespace.gsub(/[^-a-z0-9]/, '-').gsub(/^-+/, '')
+ end
+ end
+end