Project

General

Profile

« Previous | Next » 

Revision 44d2fe74

Added by Ewoud Kohl van Wijngaarden about 1 month ago

Fixes #37375 - Refactor settings to connection_string

This prefers a single connection_string setting to be used to connect to
a database. This can be anything that Sequel supports. This simplifies
configuration and also allows for easy use of an in-memory database in
testing.

The default value for sqlite_db_path is dropped so that users explicitly
need to opt in to a migration if needed.

The example settings file now reflects this.

View differences:

lib/smart_proxy_container_gateway/container_gateway.rb
default_settings :pulp_endpoint => "https://#{`hostname`.strip}",
:katello_registry_path => '/v2/',
:database_backend => 'sqlite',
:sqlite_db_path => '/var/lib/foreman-proxy/smart_proxy_container_gateway.db',
:sqlite_timeout => 30_000
# Load defaults that copy values from SETTINGS. This is done as
......
load_dependency_injection_wirings do |container_instance, settings|
container_instance.singleton_dependency :database_impl, (lambda do
if settings[:database_backend] == 'sqlite'
connection_string = "sqlite://#{settings[:sqlite_db_path]}?timeout=#{settings[:sqlite_timeout]}"
else
connection_string = settings[:postgresql_connection_string]
connection_string = settings.fetch(:db_connection_string) do
unless settings[:sqlite_db_path]
raise ValueError, 'Missing db_connection_string or sqlite_db_path option'
end
# Legacy setup
"sqlite://#{settings[:sqlite_db_path]}?timeout=#{settings[:sqlite_timeout]}"
end
Proxy::ContainerGateway::Database.new(connection_string, settings[:sqlite_db_path])

Also available in: Unified diff