X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/556da32e121396cb5f332f44c028df6fa169957c..60560d144b7abf7ff98eb12ca3a591211df19ce9:/services/api/config/arvados_config.rb diff --git a/services/api/config/arvados_config.rb b/services/api/config/arvados_config.rb index cde8acf23e..22a8fed58e 100644 --- a/services/api/config/arvados_config.rb +++ b/services/api/config/arvados_config.rb @@ -48,6 +48,13 @@ if $arvados_config_defaults.empty? raise "Missing #{::Rails.root.to_s}/config/config.default.yml" 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 $arvados_config_defaults = clusterConfig $arvados_config_defaults["ClusterID"] = clusterID @@ -106,8 +113,8 @@ arvcfg.declare_config "Collections.CollectionVersioning", Boolean, :collection_v arvcfg.declare_config "Collections.PreserveVersionIfIdle", ActiveSupport::Duration, :preserve_version_if_idle arvcfg.declare_config "Collections.TrashSweepInterval", ActiveSupport::Duration, :trash_sweep_interval arvcfg.declare_config "Collections.BlobSigningKey", NonemptyString, :blob_signing_key -arvcfg.declare_config "Collections.BlobSigningTTL", Integer, :blob_signature_ttl -arvcfg.declare_config "Collections.BlobSigning", Boolean, :permit_create_collection_with_unsigned_manifest +arvcfg.declare_config "Collections.BlobSigningTTL", ActiveSupport::Duration, :blob_signature_ttl +arvcfg.declare_config "Collections.BlobSigning", Boolean, :permit_create_collection_with_unsigned_manifest, ->(cfg, k, v) { ConfigLoader.set_cfg cfg, "Collections.BlobSigning", !v } arvcfg.declare_config "Containers.SupportedDockerImageFormats", Array, :docker_image_formats arvcfg.declare_config "Containers.LogReuseDecisions", Boolean, :log_reuse_decisions arvcfg.declare_config "Containers.DefaultKeepCacheRAM", Integer, :container_default_keep_cache_ram @@ -141,6 +148,7 @@ arvcfg.declare_config "Containers.JobsAPI.ReuseJobIfOutputsDiffer", Boolean, :re arvcfg.declare_config "Containers.JobsAPI.DefaultDockerImage", String, :default_docker_image_for_jobs arvcfg.declare_config "Mail.MailchimpAPIKey", String, :mailchimp_api_key arvcfg.declare_config "Mail.MailchimpListID", String, :mailchimp_list_id +arvcfg.declare_config "Services.Controller.ExternalURL", URI arvcfg.declare_config "Services.Workbench1.ExternalURL", URI, :workbench_address arvcfg.declare_config "Services.Websocket.ExternalURL", URI, :websocket_address arvcfg.declare_config "Services.WebDAV.ExternalURL", URI, :keep_web_service_url @@ -170,13 +178,13 @@ arvcfg.declare_config "RemoteClusters.*.Proxy", Boolean, :remote_hosts_via_dns dbcfg = ConfigLoader.new dbcfg.declare_config "PostgreSQL.ConnectionPool", Integer, :pool -dbcfg.declare_config "PostgreSQL.Connection.Host", String, :host -dbcfg.declare_config "PostgreSQL.Connection.Port", Integer, :port -dbcfg.declare_config "PostgreSQL.Connection.User", String, :username -dbcfg.declare_config "PostgreSQL.Connection.Password", String, :password -dbcfg.declare_config "PostgreSQL.Connection.DBName", String, :database -dbcfg.declare_config "PostgreSQL.Connection.Template", String, :template -dbcfg.declare_config "PostgreSQL.Connection.Encoding", String, :encoding +dbcfg.declare_config "PostgreSQL.Connection.host", String, :host +dbcfg.declare_config "PostgreSQL.Connection.port", String, :port +dbcfg.declare_config "PostgreSQL.Connection.user", String, :username +dbcfg.declare_config "PostgreSQL.Connection.password", String, :password +dbcfg.declare_config "PostgreSQL.Connection.dbname", String, :database +dbcfg.declare_config "PostgreSQL.Connection.template", String, :template +dbcfg.declare_config "PostgreSQL.Connection.encoding", String, :encoding application_config = {} %w(application.default application).each do |cfgfile| @@ -205,6 +213,14 @@ if application_config[:auto_activate_users_from] end end +if application_config[:host] || application_config[:port] || application_config[:scheme] + if !application_config[:host] || application_config[:host].empty? + raise "Must set 'host' when setting 'port' or 'scheme'" + end + $arvados_config.Services["Controller"]["ExternalURL"] = URI((application_config[:scheme] || "https")+"://"+application_config[:host]+ + (if application_config[:port] then ":#{application_config[:port]}" else "" end)) +end + # Checks for wrongly typed configuration items, coerces properties # into correct types (such as Duration), and optionally raise error # for essential configuration that can't be empty. @@ -230,16 +246,16 @@ end # rails environments. # if ::Rails.env.to_s == "test" && db_config["test"].nil? - $arvados_config["PostgreSQL"]["Connection"]["DBName"] = "arvados_test" + $arvados_config["PostgreSQL"]["Connection"]["dbname"] = "arvados_test" end -if $arvados_config["PostgreSQL"]["Connection"]["Password"].empty? +if $arvados_config["PostgreSQL"]["Connection"]["password"].empty? raise "Database password is empty, PostgreSQL section is: #{$arvados_config["PostgreSQL"]}" end -dbhost = $arvados_config["PostgreSQL"]["Connection"]["Host"] -if $arvados_config["PostgreSQL"]["Connection"]["Post"] != 0 - dbhost += ":#{$arvados_config["PostgreSQL"]["Connection"]["Post"]}" +dbhost = $arvados_config["PostgreSQL"]["Connection"]["host"] +if $arvados_config["PostgreSQL"]["Connection"]["port"] != 0 + dbhost += ":#{$arvados_config["PostgreSQL"]["Connection"]["port"]}" end # @@ -248,10 +264,10 @@ end # For config migration, we've previously populated the PostgreSQL # section of the config from database.yml # -ENV["DATABASE_URL"] = "postgresql://#{$arvados_config["PostgreSQL"]["Connection"]["User"]}:"+ - "#{$arvados_config["PostgreSQL"]["Connection"]["Password"]}@"+ - "#{dbhost}/#{$arvados_config["PostgreSQL"]["Connection"]["DBName"]}?"+ - "template=#{$arvados_config["PostgreSQL"]["Connection"]["Template"]}&"+ +ENV["DATABASE_URL"] = "postgresql://#{$arvados_config["PostgreSQL"]["Connection"]["user"]}:"+ + "#{$arvados_config["PostgreSQL"]["Connection"]["password"]}@"+ + "#{dbhost}/#{$arvados_config["PostgreSQL"]["Connection"]["dbname"]}?"+ + "template=#{$arvados_config["PostgreSQL"]["Connection"]["template"]}&"+ "encoding=#{$arvados_config["PostgreSQL"]["Connection"]["client_encoding"]}&"+ "pool=#{$arvados_config["PostgreSQL"]["ConnectionPool"]}"