diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-12-06 21:08:49 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2018-12-06 21:08:49 +0300 |
commit | 2c80a1c0de07877e6e2bf7ab20de2d4f43a0d97c (patch) | |
tree | afa7f5f54e2491e0c08168b6f4ce47511da3012b /app/controllers/projects/serverless/functions_controller.rb | |
parent | e80f89337b4be31c5531448861cedb556d02c01e (diff) |
Introduce Knative Serverless Tab
Diffstat (limited to 'app/controllers/projects/serverless/functions_controller.rb')
-rw-r--r-- | app/controllers/projects/serverless/functions_controller.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/controllers/projects/serverless/functions_controller.rb b/app/controllers/projects/serverless/functions_controller.rb new file mode 100644 index 00000000000..0af2b7ef343 --- /dev/null +++ b/app/controllers/projects/serverless/functions_controller.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module Projects + module Serverless + class FunctionsController < Projects::ApplicationController + include ProjectUnauthorized + + before_action :authorize_read_cluster! + + INDEX_PRIMING_INTERVAL = 10_000 + INDEX_POLLING_INTERVAL = 30_000 + + def index + finder = Projects::Serverless::FunctionsFinder.new(project.clusters) + + respond_to do |format| + format.json do + functions = finder.execute + + if functions.any? + Gitlab::PollingInterval.set_header(response, interval: INDEX_POLLING_INTERVAL) + render json: Projects::Serverless::ServiceSerializer.new(current_user: @current_user).represent(functions) + else + Gitlab::PollingInterval.set_header(response, interval: INDEX_PRIMING_INTERVAL) + head :no_content + end + end + + format.html do + @installed = finder.installed? + render + end + end + end + end + end +end |