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
98d2d23d
Commit
98d2d23d
authored
May 13, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract EE specific Cluster code into an EE concern
parent
f850b1bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
app/models/clusters/cluster.rb
app/models/clusters/cluster.rb
+2
-11
ee/app/models/ee/clusters/cluster.rb
ee/app/models/ee/clusters/cluster.rb
+22
-0
No files found.
app/models/clusters/cluster.rb
View file @
98d2d23d
module
Clusters
module
Clusters
class
Cluster
<
ActiveRecord
::
Base
class
Cluster
<
ActiveRecord
::
Base
prepend
EE
::
Clusters
::
Cluster
include
Presentable
include
Presentable
prepend
HasEnvironmentScope
self
.
table_name
=
'clusters'
self
.
table_name
=
'clusters'
...
@@ -32,7 +33,6 @@ module Clusters
...
@@ -32,7 +33,6 @@ module Clusters
accepts_nested_attributes_for
:platform_kubernetes
,
update_only:
true
accepts_nested_attributes_for
:platform_kubernetes
,
update_only:
true
validates
:name
,
cluster_name:
true
validates
:name
,
cluster_name:
true
validate
:unique_environment_scope
validate
:restrict_modification
,
on: :update
validate
:restrict_modification
,
on: :update
delegate
:status
,
to: :provider
,
allow_nil:
true
delegate
:status
,
to: :provider
,
allow_nil:
true
...
@@ -105,15 +105,6 @@ module Clusters
...
@@ -105,15 +105,6 @@ module Clusters
private
private
def
unique_environment_scope
if
project
&&
project
.
clusters
.
where
(
environment_scope:
environment_scope
).
where
.
not
(
id:
self
.
id
).
exists?
errors
.
add
(
:base
,
"cannot add duplicated environment scope"
)
return
false
end
true
end
def
restrict_modification
def
restrict_modification
if
provider
&
.
on_creation?
if
provider
&
.
on_creation?
errors
.
add
(
:base
,
"cannot modify during creation"
)
errors
.
add
(
:base
,
"cannot modify during creation"
)
...
...
ee/app/models/ee/clusters/cluster.rb
0 → 100644
View file @
98d2d23d
module
EE
module
Clusters
module
Cluster
extend
ActiveSupport
::
Concern
prepended
do
prepend
HasEnvironmentScope
validate
:unique_environment_scope
end
def
unique_environment_scope
if
project
&&
project
.
clusters
.
where
(
environment_scope:
environment_scope
).
where
.
not
(
id:
self
.
id
).
exists?
errors
.
add
(
:base
,
"cannot add duplicated environment scope"
)
return
false
end
true
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