13647: Update keepstore install docs, eliminate keep_services step.
[arvados.git] / services / api / app / controllers / arvados / v1 / keep_services_controller.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 class Arvados::V1::KeepServicesController < ApplicationController
6
7   skip_before_action :find_object_by_uuid, only: :accessible
8   skip_before_action :render_404_if_no_object, only: :accessible
9   skip_before_action :require_auth_scope, only: :accessible
10
11   def find_objects_for_index
12     # all users can list all keep services
13     @objects = from_config_or_db
14     super
15   end
16
17   def accessible
18     if request.headers['X-External-Client'] == '1'
19       @objects = from_config_or_db.where('service_type=?', 'proxy')
20     else
21       @objects = from_config_or_db.where('service_type<>?', 'proxy')
22     end
23     render_list
24   end
25
26   private
27
28   # return the set of keep services from the database (if this is an
29   # older installation or test system where entries have been added
30   # manually) or, preferably, the cluster config file.
31   def from_config_or_db
32     if KeepService.all.count == 0
33       KeepService.from_config
34     else
35       KeepService.all
36     end
37   end
38 end