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
ecda32ea
Commit
ecda32ea
authored
Dec 10, 2018
by
Dylan Griffith
Committed by
Bob Van Landuyt
Dec 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract Clusters::BuildService
parent
01dc3c96
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
21 deletions
+52
-21
app/controllers/clusters/clusters_controller.rb
app/controllers/clusters/clusters_controller.rb
+6
-21
app/services/clusters/build_service.rb
app/services/clusters/build_service.rb
+21
-0
spec/services/clusters/build_service_spec.rb
spec/services/clusters/build_service_spec.rb
+25
-0
No files found.
app/controllers/clusters/clusters_controller.rb
View file @
ecda32ea
...
...
@@ -181,30 +181,15 @@ class Clusters::ClustersController < Clusters::BaseController
end
def
gcp_cluster
@gcp_cluster
=
new_cluster
do
|
cluster
|
cluster
.
build_provider_gcp
end
cluster
=
Clusters
::
BuildService
.
new
(
clusterable
.
subject
).
execute
cluster
.
build_provider_gcp
@gcp_cluster
=
cluster
.
present
(
current_user:
current_user
)
end
def
user_cluster
@user_cluster
=
new_cluster
do
|
cluster
|
cluster
.
build_platform_kubernetes
end
end
def
new_cluster
::
Clusters
::
Cluster
.
new
.
tap
do
|
cluster
|
yield
cluster
case
clusterable
.
subject
when
::
Project
cluster
.
cluster_type
=
:project_type
when
::
Group
cluster
.
cluster_type
=
:group_type
else
raise
NotImplementedError
end
end
.
present
(
current_user:
current_user
)
cluster
=
Clusters
::
BuildService
.
new
(
clusterable
.
subject
).
execute
cluster
.
build_platform_kubernetes
@user_cluster
=
cluster
.
present
(
current_user:
current_user
)
end
def
validate_gcp_token
...
...
app/services/clusters/build_service.rb
0 → 100644
View file @
ecda32ea
# frozen_string_literal: true
module
Clusters
class
BuildService
def
initialize
(
subject
)
@subject
=
subject
end
def
execute
::
Clusters
::
Cluster
.
new
.
tap
do
|
cluster
|
case
@subject
when
::
Project
cluster
.
cluster_type
=
:project_type
when
::
Group
cluster
.
cluster_type
=
:group_type
else
raise
NotImplementedError
end
end
end
end
end
spec/services/clusters/build_service_spec.rb
0 → 100644
View file @
ecda32ea
# frozen_string_literal: true
require
'spec_helper'
describe
Clusters
::
BuildService
do
describe
'#execute'
do
subject
{
described_class
.
new
(
cluster_subject
).
execute
}
describe
'when cluster subject is a project'
do
let
(
:cluster_subject
)
{
build
(
:project
)
}
it
'sets the cluster_type to project_type'
do
is_expected
.
to
be_project_type
end
end
describe
'when cluster subject is a group'
do
let
(
:cluster_subject
)
{
build
(
:group
)
}
it
'sets the cluster_type to group_type'
do
is_expected
.
to
be_group_type
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