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
44c9bf36
Commit
44c9bf36
authored
Feb 09, 2021
by
Tiger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use nullify_if_blank for cluster_platforms_kubernetes.namespace
parent
5e149b3d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
13 deletions
+5
-13
app/models/clusters/platforms/kubernetes.rb
app/models/clusters/platforms/kubernetes.rb
+3
-5
spec/models/clusters/platforms/kubernetes_spec.rb
spec/models/clusters/platforms/kubernetes_spec.rb
+2
-8
No files found.
app/models/clusters/platforms/kubernetes.rb
View file @
44c9bf36
...
...
@@ -7,6 +7,7 @@ module Clusters
include
EnumWithNil
include
AfterCommitQueue
include
ReactiveCaching
include
NullifyIfBlank
RESERVED_NAMESPACES
=
%w(gitlab-managed-apps)
.
freeze
...
...
@@ -25,7 +26,6 @@ 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
...
...
@@ -64,6 +64,8 @@ module Clusters
default_value_for
:authorization_type
,
:rbac
nullify_if_blank
:namespace
def
predefined_variables
(
project
:,
environment_name
:,
kubernetes_namespace:
nil
)
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
tap
do
|
variables
|
variables
.
append
(
key:
'KUBE_URL'
,
value:
api_url
)
...
...
@@ -255,10 +257,6 @@ module Clusters
true
end
def
nullify_blank_namespace
self
.
namespace
=
nil
if
namespace
.
blank?
end
def
extract_relevant_pod_data
(
pods
)
pods
.
map
do
|
pod
|
{
...
...
spec/models/clusters/platforms/kubernetes_spec.rb
View file @
44c9bf36
...
...
@@ -17,6 +17,8 @@ RSpec.describe Clusters::Platforms::Kubernetes do
it
{
is_expected
.
to
delegate_method
(
:enabled?
).
to
(
:cluster
)
}
it
{
is_expected
.
to
delegate_method
(
:provided_by_user?
).
to
(
:cluster
)
}
it
{
is_expected
.
to
nullify_if_blank
(
:namespace
)
}
it_behaves_like
'having unique enum values'
describe
'before_validation'
do
...
...
@@ -29,14 +31,6 @@ RSpec.describe Clusters::Platforms::Kubernetes 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
...
...
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