Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
61283d51
Commit
61283d51
authored
Dec 04, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve name validation for cluster
parent
2871d302
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
app/validators/cluster_name_validator.rb
app/validators/cluster_name_validator.rb
+5
-5
No files found.
app/validators/cluster_name_validator.rb
View file @
61283d51
...
...
@@ -3,11 +3,7 @@
# Custom validator for ClusterName.
class
ClusterNameValidator
<
ActiveModel
::
EachValidator
def
validate_each
(
record
,
attribute
,
value
)
if
record
.
user?
unless
value
.
present?
record
.
errors
.
add
(
attribute
,
" has to be present"
)
end
elsif
record
.
gcp?
if
record
.
managed?
if
record
.
persisted?
&&
record
.
name_changed?
record
.
errors
.
add
(
attribute
,
" can not be changed because it's synchronized with provider"
)
end
...
...
@@ -19,6 +15,10 @@ class ClusterNameValidator < ActiveModel::EachValidator
unless
value
=~
Gitlab
::
Regex
.
kubernetes_namespace_regex
record
.
errors
.
add
(
attribute
,
Gitlab
::
Regex
.
kubernetes_namespace_regex_message
)
end
else
unless
value
.
present?
record
.
errors
.
add
(
attribute
,
" has to be present"
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment