diff options
author | Dylan William Hardison <dylan@hardison.net> | 2016-07-04 16:43:48 +0200 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2016-09-10 18:40:58 +0200 |
commit | 1e2027a97adb7481c7cb296330039313fefd95c6 (patch) | |
tree | f8f900af1e38e4020c8580c58cd3e2faa54a6569 /Bugzilla | |
parent | c61b7ce75f229d4034099e8e93c56d98208bc799 (diff) | |
download | bugzilla-1e2027a97adb7481c7cb296330039313fefd95c6.tar.gz bugzilla-1e2027a97adb7481c7cb296330039313fefd95c6.tar.xz |
Bug 1284263 - Add optional support for $DATABASE_URL instead of localconfig for db_* connection params.
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Install/Localconfig.pm | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Bugzilla/Install/Localconfig.pm b/Bugzilla/Install/Localconfig.pm index 82ec9ae35..d591ece15 100644 --- a/Bugzilla/Install/Localconfig.pm +++ b/Bugzilla/Install/Localconfig.pm @@ -60,6 +60,10 @@ use constant LOCALCONFIG_VARS => ( default => 0, }, { + name => 'db_from_env', + default => 0, + }, + { name => 'db_driver', default => 'sqlite', }, @@ -198,6 +202,25 @@ sub read_localconfig { } } } + require Bugzilla::Error; + if ($localconfig{db_from_env}) { + if (Bugzilla->has_feature('db_from_env')) { + require URI::db; + unless ($ENV{DATABASE_URL}) { + Bugzilla::Error::ThrowUserError('missing_database_url'); + } + my $uri = URI::db->new($ENV{DATABASE_URL}); + $localconfig{db_driver} = $uri->canonical_engine; + $localconfig{db_name} = $uri->dbname; + $localconfig{db_host} = $uri->host; + $localconfig{db_user} = $uri->user; + $localconfig{db_pass} = $uri->password; + $localconfig{db_port} = $uri->port // 0; + } + else { + Bugzilla::Error::ThrowUserError('feature_disabled', { feature => 'db_from_env' }); + } + } return \%localconfig; } @@ -233,6 +256,7 @@ sub update_localconfig { my $output = $params->{output} || 0; my $answer = Bugzilla->installation_answers; my $localconfig = read_localconfig('include deprecated'); + my $db_from_env = Bugzilla->localconfig->{db_from_env}; my @new_vars; foreach my $var (LOCALCONFIG_VARS) { @@ -258,7 +282,7 @@ sub update_localconfig { # an answer file, then we don't notify about site_wide_secret # because we assume the intent was to auto-generate it anyway. if (!scalar(keys %$answer) || $name ne 'site_wide_secret') { - push(@new_vars, $name); + push(@new_vars, $name) unless $db_from_env && $name =~ /^db_(?!from_env)/; } $localconfig->{$name} = $var->{default}; } @@ -298,6 +322,9 @@ sub update_localconfig { foreach my $var (LOCALCONFIG_VARS) { my $name = $var->{name}; my $desc = $var->{desc}; + + next if $db_from_env && $name =~ /^db_(?!from_env)/; + if(!length $desc){ $desc = install_string("localconfig_$name", { root => ROOT_USER }); chomp($desc); |