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
Show 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
...
@@ -23,11 +23,12 @@ module Clusters
key:
Settings
.
attr_encrypted_db_key_base_truncated
,
key:
Settings
.
attr_encrypted_db_key_base_truncated
,
algorithm:
'aes-256-cbc'
algorithm:
'aes-256-cbc'
before_validation
:nullify_blank_namespace
before_validation
:enforce_namespace_to_lower_case
before_validation
:enforce_namespace_to_lower_case
before_validation
:enforce_ca_whitespace_trimming
before_validation
:enforce_ca_whitespace_trimming
validates
:namespace
,
validates
:namespace
,
allow_
blank
:
true
,
allow_
nil
:
true
,
length:
1
..
63
,
length:
1
..
63
,
format:
{
format:
{
with:
Gitlab
::
Regex
.
kubernetes_namespace_regex
,
with:
Gitlab
::
Regex
.
kubernetes_namespace_regex
,
...
@@ -190,6 +191,10 @@ module Clusters
...
@@ -190,6 +191,10 @@ module Clusters
true
true
end
end
def
nullify_blank_namespace
self
.
namespace
=
nil
if
namespace
.
blank?
end
end
end
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
...
@@ -19,14 +19,23 @@ describe Clusters::Platforms::Kubernetes do
it_behaves_like
'having unique enum values'
it_behaves_like
'having unique enum values'
describe
'before_validation'
do
describe
'before_validation'
do
context
'when namespace includes upper case'
do
let
(
:kubernetes
)
{
create
(
:cluster_platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
let
(
:kubernetes
)
{
create
(
:cluster_platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
context
'when namespace includes upper case'
do
let
(
:namespace
)
{
'ABC'
}
let
(
:namespace
)
{
'ABC'
}
it
'converts to lower case'
do
it
'converts to lower case'
do
expect
(
kubernetes
.
namespace
).
to
eq
(
'abc'
)
expect
(
kubernetes
.
namespace
).
to
eq
(
'abc'
)
end
end
end
end
context
'when namespace is blank'
do
let
(
:namespace
)
{
''
}
it
'nullifies the namespace'
do
expect
(
kubernetes
.
namespace
).
to
be_nil
end
end
end
end
describe
'validation'
do
describe
'validation'
do
...
@@ -35,8 +44,8 @@ describe Clusters::Platforms::Kubernetes do
...
@@ -35,8 +44,8 @@ describe Clusters::Platforms::Kubernetes do
context
'when validates namespace'
do
context
'when validates namespace'
do
let
(
:kubernetes
)
{
build
(
:cluster_platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
let
(
:kubernetes
)
{
build
(
:cluster_platform_kubernetes
,
:configured
,
namespace:
namespace
)
}
context
'when namespace is
blank
'
do
context
'when namespace is
nil
'
do
let
(
:namespace
)
{
''
}
let
(
:namespace
)
{
nil
}
it
{
is_expected
.
to
be_truthy
}
it
{
is_expected
.
to
be_truthy
}
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