Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-11-02 17:31:25 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2017-11-02 17:31:25 +0300
commit30938b898c5415d8ec5cdf6c9851c45c1464c1a0 (patch)
tree39414abe26bb1eff4fea56cbff2a4eb356d03474
parent64be8d70ae20928df351e495a3442bb6036bc3e7 (diff)
Fix and add applications controller
-rw-r--r--app/controllers/projects/clusters/applications_controller.rb14
-rw-r--r--app/models/clusters/applications/helm.rb2
-rw-r--r--app/workers/concerns/cluster_app.rb2
-rw-r--r--config/routes/project.rb4
4 files changed, 9 insertions, 13 deletions
diff --git a/app/controllers/projects/clusters/applications_controller.rb b/app/controllers/projects/clusters/applications_controller.rb
index 438e1853435..cdebbdefb3f 100644
--- a/app/controllers/projects/clusters/applications_controller.rb
+++ b/app/controllers/projects/clusters/applications_controller.rb
@@ -4,18 +4,14 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
before_action :authorize_read_cluster!
before_action :authorize_create_cluster!, only: [:create]
- def new
- end
-
def create
return render_404 if application
- new_application = application_class.create(cluster: cluster)
-
respond_to do |format|
format.json do
- if new_application.persisted?
- head :ok
+ # TODO: Do that via Service
+ if application_class.create(cluster: cluster).persisted?
+ head :no_data
else
head :bad_request
end
@@ -26,11 +22,11 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
private
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
def application_class
- Clusters::Cluster::Applications.find(params[:application])
+ Clusters::Cluster::APPLICATIONS[params[:application]] || render_404
end
def application
diff --git a/app/models/clusters/applications/helm.rb b/app/models/clusters/applications/helm.rb
index 59e0076c8df..a18a3f87bc4 100644
--- a/app/models/clusters/applications/helm.rb
+++ b/app/models/clusters/applications/helm.rb
@@ -7,7 +7,7 @@ module Clusters
include ::Clusters::Concerns::AppStatus
- belongs_to :cluser, class_name: 'Clusters::Cluster', foreign_key: :cluster_id
+ belongs_to :cluster, class_name: 'Clusters::Cluster', foreign_key: :cluster_id
default_value_for :version, Gitlab::Clusters::Helm::HELM_VERSION
diff --git a/app/workers/concerns/cluster_app.rb b/app/workers/concerns/cluster_app.rb
index a0202901f15..947cdaefcb7 100644
--- a/app/workers/concerns/cluster_app.rb
+++ b/app/workers/concerns/cluster_app.rb
@@ -3,7 +3,7 @@ module ClusterApp
included do
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?
end
end
diff --git a/config/routes/project.rb b/config/routes/project.rb
index a6a7c5e7482..55dab840dca 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -191,8 +191,8 @@ constraints(ProjectUrlConstrainer.new) do
member do
get :status, format: :json
- scope '*application' do
- resource :applications, only: [:create]
+ scope :applications do
+ get '/*application', to: 'clusters/applications#create'
end
end
end