diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-11 18:08:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-11 18:08:58 +0000 |
commit | 1ca9950d5f890cd8f185e1eda158b969a7244fe2 (patch) | |
tree | 6f62715938a4b2b001705c51c697609a8e0850ae /app/controllers | |
parent | bcc77054ee9aefd1e332e04a4189390fd5a3112e (diff) | |
download | gitlab-ce-1ca9950d5f890cd8f185e1eda158b969a7244fe2.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/admin/services_controller.rb | 12 | ||||
-rw-r--r-- | app/controllers/projects/serverless/functions_controller.rb | 15 |
2 files changed, 17 insertions, 10 deletions
diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb index 9cea25cc7fe..e31e0e09978 100644 --- a/app/controllers/admin/services_controller.rb +++ b/app/controllers/admin/services_controller.rb @@ -7,7 +7,7 @@ class Admin::ServicesController < Admin::ApplicationController before_action :service, only: [:edit, :update] def index - @services = instance_level_services + @services = services_templates end def edit @@ -19,7 +19,7 @@ class Admin::ServicesController < Admin::ApplicationController def update if service.update(service_params[:service]) - PropagateInstanceLevelServiceWorker.perform_async(service.id) if service.active? + PropagateServiceTemplateWorker.perform_async(service.id) if service.active? redirect_to admin_application_settings_services_path, notice: 'Application settings saved successfully' @@ -31,17 +31,17 @@ class Admin::ServicesController < Admin::ApplicationController private # rubocop: disable CodeReuse/ActiveRecord - def instance_level_services + def services_templates Service.available_services_names.map do |service_name| - service = "#{service_name}_service".camelize.constantize - service.where(instance: true).first_or_create + service_template = "#{service_name}_service".camelize.constantize + service_template.where(template: true).first_or_create end end # rubocop: enable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord def service - @service ||= Service.where(id: params[:id], instance: true).first + @service ||= Service.where(id: params[:id], template: true).first end # rubocop: enable CodeReuse/ActiveRecord diff --git a/app/controllers/projects/serverless/functions_controller.rb b/app/controllers/projects/serverless/functions_controller.rb index 4b0d001fca6..0b55414d390 100644 --- a/app/controllers/projects/serverless/functions_controller.rb +++ b/app/controllers/projects/serverless/functions_controller.rb @@ -8,11 +8,15 @@ module Projects def index respond_to do |format| format.json do - functions = finder.execute + functions = finder.execute.select do |function| + can?(@current_user, :read_cluster, function.cluster) + end + + serialized_functions = serialize_function(functions) render json: { knative_installed: finder.knative_installed, - functions: serialize_function(functions) + functions: serialized_functions }.to_json end @@ -23,11 +27,14 @@ module Projects end def show - @service = serialize_function(finder.service(params[:environment_id], params[:id])) - @prometheus = finder.has_prometheus?(params[:environment_id]) + function = finder.service(params[:environment_id], params[:id]) + return not_found unless function && can?(@current_user, :read_cluster, function.cluster) + @service = serialize_function(function) return not_found if @service.nil? + @prometheus = finder.has_prometheus?(params[:environment_id]) + respond_to do |format| format.json do render json: @service |