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
Léo-Paul Géneau
gitlab-ce
Commits
30938b89
Commit
30938b89
authored
Nov 02, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix and add applications controller
parent
64be8d70
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
13 deletions
+9
-13
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
+1
-1
app/workers/concerns/cluster_app.rb
app/workers/concerns/cluster_app.rb
+1
-1
config/routes/project.rb
config/routes/project.rb
+2
-2
No files found.
app/controllers/projects/clusters/applications_controller.rb
View file @
30938b89
...
@@ -4,18 +4,14 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
...
@@ -4,18 +4,14 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
before_action
:authorize_read_cluster!
before_action
:authorize_read_cluster!
before_action
:authorize_create_cluster!
,
only:
[
:create
]
before_action
:authorize_create_cluster!
,
only:
[
:create
]
def
new
end
def
create
def
create
return
render_404
if
application
return
render_404
if
application
new_application
=
application_class
.
create
(
cluster:
cluster
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
json
do
format
.
json
do
if
new_application
.
persisted?
# TODO: Do that via Service
head
:ok
if
application_class
.
create
(
cluster:
cluster
).
persisted?
head
:no_data
else
else
head
:bad_request
head
:bad_request
end
end
...
@@ -26,11 +22,11 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
...
@@ -26,11 +22,11 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
private
private
def
cluster
def
cluster
@cluster
||=
project
.
clusters
.
find
_by
(
cluster_id:
params
[
:cluster_id
]).
present
(
current_user:
current_user
)
@cluster
||=
project
.
clusters
.
find
(
params
[
:id
])
||
render_404
end
end
def
application_class
def
application_class
Clusters
::
Cluster
::
A
pplications
.
find
(
params
[
:application
])
Clusters
::
Cluster
::
A
PPLICATIONS
[
params
[
:application
]]
||
render_404
end
end
def
application
def
application
...
...
app/models/clusters/applications/helm.rb
View file @
30938b89
...
@@ -7,7 +7,7 @@ module Clusters
...
@@ -7,7 +7,7 @@ module Clusters
include
::
Clusters
::
Concerns
::
AppStatus
include
::
Clusters
::
Concerns
::
AppStatus
belongs_to
:cluser
,
class_name:
'Clusters::Cluster'
,
foreign_key: :cluster_id
belongs_to
:clus
t
er
,
class_name:
'Clusters::Cluster'
,
foreign_key: :cluster_id
default_value_for
:version
,
Gitlab
::
Clusters
::
Helm
::
HELM_VERSION
default_value_for
:version
,
Gitlab
::
Clusters
::
Helm
::
HELM_VERSION
...
...
app/workers/concerns/cluster_app.rb
View file @
30938b89
...
@@ -3,7 +3,7 @@ module ClusterApp
...
@@ -3,7 +3,7 @@ module ClusterApp
included
do
included
do
def
find_app
(
app_name
,
id
)
def
find_app
(
app_name
,
id
)
Clusters
::
Applications
.
const_get
(
app_name
.
classify
)
.
find
(
id
).
try
do
|
app
|
Clusters
::
Cluster
::
APPLICATIONS
[
app_name
]
.
find
(
id
).
try
do
|
app
|
yield
(
app
)
if
block_given?
yield
(
app
)
if
block_given?
end
end
end
end
...
...
config/routes/project.rb
View file @
30938b89
...
@@ -191,8 +191,8 @@ constraints(ProjectUrlConstrainer.new) do
...
@@ -191,8 +191,8 @@ constraints(ProjectUrlConstrainer.new) do
member
do
member
do
get
:status
,
format: :json
get
:status
,
format: :json
scope
'*application'
do
scope
:applications
do
resource
:applications
,
only:
[
:create
]
get
'/*application'
,
to:
'clusters/applications#create'
end
end
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