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
49210dff
Commit
49210dff
authored
Nov 03, 2017
by
Alessio Caiazza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Schedule k8s application installation with a service
parent
1ca9aaf8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
9 deletions
+42
-9
app/controllers/projects/clusters/applications_controller.rb
app/controllers/projects/clusters/applications_controller.rb
+5
-9
app/models/clusters/applications/helm.rb
app/models/clusters/applications/helm.rb
+2
-0
app/models/clusters/concerns/application_status.rb
app/models/clusters/concerns/application_status.rb
+8
-0
app/services/clusters/applications/schedule_installation_service.rb
...es/clusters/applications/schedule_installation_service.rb
+27
-0
No files found.
app/controllers/projects/clusters/applications_controller.rb
View file @
49210dff
...
...
@@ -5,12 +5,12 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
before_action
:authorize_create_cluster!
,
only:
[
:create
]
def
create
return
render_404
if
application
respond_to
do
|
format
|
format
.
json
do
# TODO: Do that via Service
if
application_class
.
create
(
cluster:
cluster
).
persisted?
scheduled
=
Clusters
::
Applications
::
ScheduleInstallationService
.
new
(
project
,
current_user
,
application_class:
@application_class
,
cluster:
@cluster
).
execute
if
scheduled
head
:no_data
else
head
:bad_request
...
...
@@ -26,10 +26,6 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
end
def
application_class
Clusters
::
Cluster
::
APPLICATIONS
[
params
[
:application
]]
||
render_404
end
def
application
application_class
.
find_by
(
cluster:
cluster
)
@application_class
||=
Clusters
::
Cluster
::
APPLICATIONS
[
params
[
:application
]]
||
render_404
end
end
app/models/clusters/applications/helm.rb
View file @
49210dff
...
...
@@ -11,6 +11,8 @@ module Clusters
default_value_for
:version
,
Gitlab
::
Kubernetes
::
Helm
::
HELM_VERSION
validates
:cluster
,
presence:
true
def
name
NAME
end
...
...
app/models/clusters/concerns/application_status.rb
View file @
49210dff
...
...
@@ -23,6 +23,14 @@ module Clusters
transition
any
-
[
:errored
]
=>
:errored
end
event
:make_scheduled
do
transition
%i(installable errored)
=>
:scheduled
end
before_transition
any
=>
[
:scheduled
]
do
|
app_status
,
_
|
app_status
.
status_reason
=
nil
end
before_transition
any
=>
[
:errored
]
do
|
app_status
,
transition
|
status_reason
=
transition
.
args
.
first
app_status
.
status_reason
=
status_reason
if
status_reason
...
...
app/services/clusters/applications/schedule_installation_service.rb
0 → 100644
View file @
49210dff
module
Clusters
module
Applications
class
ScheduleInstallationService
<
::
BaseService
def
execute
application
=
application_class
.
find_or_create_by!
(
cluster:
cluster
)
application
.
make_scheduled!
ClusterInstallAppWorker
.
perform_async
(
application
.
name
,
application
.
id
)
true
rescue
ActiveRecord
::
RecordInvalid
false
rescue
StateMachines
::
InvalidTransition
false
end
private
def
application_class
params
[
:application_class
]
end
def
cluster
params
[
:cluster
]
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