# /etc/arvados/config.yml, you will be able to delete application.yml.
require 'config_loader'
-
-begin
- # If secret_token.rb exists here, we need to load it first.
- require_relative 'secret_token.rb'
-rescue LoadError
- # Normally secret_token.rb is missing and the secret token is
- # configured by application.yml (i.e., here!) instead.
-end
-
-# Load the defaults
-$arvados_config_defaults = ConfigLoader.load "#{::Rails.root.to_s}/config/config.default.yml"
-if $arvados_config_defaults.empty?
- raise "Missing #{::Rails.root.to_s}/config/config.default.yml"
+require 'config_validators'
+require 'open3'
+
+# Load the defaults, used by config:migrate and fallback loading
+# legacy application.yml
+defaultYAML, stderr, status = Open3.capture3("arvados-server", "config-dump", "-config=-", "-skip-legacy", stdin_data: "Clusters: {xxxxx: {}}")
+if !status.success?
+ puts stderr
+ raise "error loading config: #{status}"
end
-
-def remove_sample_entries(h)
- return unless h.is_a? Hash
- h.delete("SAMPLE")
- h.each { |k, v| remove_sample_entries(v) }
-end
-remove_sample_entries($arvados_config_defaults)
-
-clusterID, clusterConfig = $arvados_config_defaults["Clusters"].first
+confs = YAML.load(defaultYAML, deserialize_symbols: false)
+clusterID, clusterConfig = confs["Clusters"].first
$arvados_config_defaults = clusterConfig
$arvados_config_defaults["ClusterID"] = clusterID
-# Initialize the global config with the defaults
-$arvados_config_global = $arvados_config_defaults.deep_dup
-
# Load the global config file
-confs = ConfigLoader.load "/etc/arvados/config.yml"
-if !confs.empty?
- clusterID, clusterConfig = confs["Clusters"].first
- $arvados_config_global["ClusterID"] = clusterID
-
- # Copy the cluster config over the defaults
- $arvados_config_global.deep_merge!(clusterConfig)
+Open3.popen2("arvados-server", "config-dump", "-skip-legacy") do |stdin, stdout, status_thread|
+ confs = YAML.load(stdout, deserialize_symbols: false)
+ if confs && !confs.empty?
+ # config-dump merges defaults with user configuration, so every
+ # key should be set.
+ clusterID, clusterConfig = confs["Clusters"].first
+ $arvados_config_global = clusterConfig
+ $arvados_config_global["ClusterID"] = clusterID
+ else
+ # config-dump failed, assume we will be loading from legacy
+ # application.yml, initialize with defaults.
+ $arvados_config_global = $arvados_config_defaults.deep_dup
+ end
end
# Now make a copy
arvcfg.declare_config "ManagementToken", String, :ManagementToken
arvcfg.declare_config "TLS.Insecure", Boolean, :arvados_insecure_https
+arvcfg.declare_config "Collections.TrustAllContent", Boolean, :trust_all_content
arvcfg.declare_config "Services.Controller.ExternalURL", URI, :arvados_v1_base, ->(cfg, k, v) {
u = URI(v)
arvcfg.declare_config "Users.AnonymousUserToken", String, :anonymous_user_token
-arvcfg.declare_config "Workbench.SecretToken", String, :secret_token
arvcfg.declare_config "Workbench.SecretKeyBase", String, :secret_key_base
arvcfg.declare_config "Workbench.ApplicationMimetypesWithViewIcon", Hash, :application_mimetypes_with_view_icon, ->(cfg, k, v) {
arvcfg.declare_config "Workbench.RunningJobLogRecordsToFetch", Integer, :running_job_log_records_to_fetch
arvcfg.declare_config "Workbench.LogViewerMaxBytes", Integer, :log_viewer_max_bytes
-arvcfg.declare_config "Workbench.TrustAllContent", Boolean, :trust_all_content
-arvcfg.declare_config "Workbench.UserProfileFormFields", Array, :user_profile_form_fields, ->(cfg, k, v) {
+arvcfg.declare_config "Workbench.ProfilingEnabled", Boolean, :profiling_enabled
+arvcfg.declare_config "Workbench.APIResponseCompression", Boolean, :api_response_compression
+arvcfg.declare_config "Workbench.UserProfileFormFields", Hash, :user_profile_form_fields, ->(cfg, k, v) {
if !v
v = []
end
- ConfigLoader.set_cfg cfg, "Workbench.UserProfileFormFields", v
+ entries = {}
+ v.each_with_index do |s,i|
+ entries[s["key"]] = {
+ "Type" => s["type"],
+ "FormFieldTitle" => s["form_field_title"],
+ "FormFieldDescription" => s["form_field_description"],
+ "Required" => s["required"],
+ "Position": i
+ }
+ if s["options"]
+ entries[s["key"]]["Options"] = {}
+ s["options"].each do |o|
+ entries[s["key"]]["Options"][o] = {}
+ end
+ end
+ end
+ ConfigLoader.set_cfg cfg, "Workbench.UserProfileFormFields", entries
}
arvcfg.declare_config "Workbench.UserProfileFormMessage", String, :user_profile_form_message
arvcfg.declare_config "Workbench.Theme", String, :arvados_theme
ConfigLoader.copy_into_config $arvados_config, config
ConfigLoader.copy_into_config $remaining_config, config
secrets.secret_key_base = $arvados_config["Workbench"]["SecretKeyBase"]
+ ConfigValidators.validate_wb2_url_config()
+ ConfigValidators.validate_download_config()
+
end