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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
f114bb5a
Commit
f114bb5a
authored
Sep 25, 2019
by
Tiger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nullify platform Kubernetes namespace if blank
parent
cde4a645
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
app/models/clusters/platforms/kubernetes.rb
app/models/clusters/platforms/kubernetes.rb
+6
-1
changelogs/unreleased/31728-nullify-cluster-namespace-if-blank.yml
...s/unreleased/31728-nullify-cluster-namespace-if-blank.yml
+5
-0
spec/models/clusters/platforms/kubernetes_spec.rb
spec/models/clusters/platforms/kubernetes_spec.rb
+12
-3
No files found.
app/models/clusters/platforms/kubernetes.rb
View file @
f114bb5a
...
...
@@ -23,11 +23,12 @@ module Clusters
key:
Settings
.
attr_encrypted_db_key_base_truncated
,
algorithm:
'aes-256-cbc'
before_validation
:nullify_blank_namespace
before_validation
:enforce_namespace_to_lower_case
before_validation
:enforce_ca_whitespace_trimming
validates
:namespace
,
allow_
blank
:
true
,
allow_
nil
:
true
,
length:
1
..
63
,
format:
{
with:
Gitlab
::
Regex
.
kubernetes_namespace_regex
,
...
...
@@ -190,6 +191,10 @@ module Clusters
true
end
def
nullify_blank_namespace
self
.
namespace
=
nil
if
namespace
.
blank?
end
end
end
end
...
...
changelogs/unreleased/31728-nullify-cluster-namespace-if-blank.yml
0 → 100644
View file @
f114bb5a
---
title
:
Nullify platform Kubernetes namespace if blank
merge_request
:
17657
author
:
type
:
fixed
spec/models/clusters/platforms/kubernetes_spec.rb
View file @
f114bb5a
...
...
@@ -19,14 +19,23 @@ describe Clusters::Platforms::Kubernetes do
it_behaves_like
'having unique enum values'
describe
'before_validation'
do
let
(
:kubernetes
)
{
create
(
:cluster_platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
context
'when namespace includes upper case'
do
let
(
:kubernetes
)
{
create
(
:cluster_platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
let
(
:namespace
)
{
'ABC'
}
it
'converts to lower case'
do
expect
(
kubernetes
.
namespace
).
to
eq
(
'abc'
)
end
end
context
'when namespace is blank'
do
let
(
:namespace
)
{
''
}
it
'nullifies the namespace'
do
expect
(
kubernetes
.
namespace
).
to
be_nil
end
end
end
describe
'validation'
do
...
...
@@ -35,8 +44,8 @@ describe Clusters::Platforms::Kubernetes do
context
'when validates namespace'
do
let
(
:kubernetes
)
{
build
(
:cluster_platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
context
'when namespace is
blank
'
do
let
(
:namespace
)
{
''
}
context
'when namespace is
nil
'
do
let
(
:namespace
)
{
nil
}
it
{
is_expected
.
to
be_truthy
}
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