21121: Get keep byte usage from Prometheus
[arvados.git] / apps / workbench / lib / config_validators.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'uri'
6
7 module ConfigValidators
8   def self.validate_wb2_url_config
9     if Rails.configuration.Services.Workbench2.ExternalURL != URI("")
10       if !Rails.configuration.Services.Workbench2.ExternalURL.is_a?(URI::HTTP)
11         raise "workbench2_url config is not an HTTP URL: #{Rails.configuration.Services.Workbench2.ExternalURL}"
12       elsif /.*[\/]{2,}$/.match(Rails.configuration.Services.Workbench2.ExternalURL.to_s)
13         raise "workbench2_url config shouldn't have multiple trailing slashes: #{Rails.configuration.Services.Workbench2.ExternalURL}"
14       else
15         return true
16       end
17     end
18     return false
19   end
20
21   def self.validate_download_config
22     if Rails.configuration.Services.WebDAV.ExternalURL == URI("") and Rails.configuration.Services.WebDAVDownload.ExternalURL == URI("")
23       raise "Keep-web service must be configured in Services.WebDAV and/or Services.WebDAVDownload"
24     end
25   end
26 end