From 06c9e771396510cf34e94189404e95430757fe55 Mon Sep 17 00:00:00 2001 From: Benedikt Trefzer Date: Sun, 22 Oct 2017 15:32:48 +0200 Subject: [PATCH] allow to specify drivername for postgresql db Change-Id: Idbac640aba8f4c87ae43df3a7019bf465895ca43 --- manifests/db.pp | 4 ++-- releasenotes/notes/postgresql-590a36045748761a.yaml | 5 +++++ spec/defines/oslo_db_spec.rb | 8 ++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/postgresql-590a36045748761a.yaml diff --git a/manifests/db.pp b/manifests/db.pp index 3fff658..08711eb 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -138,7 +138,7 @@ define oslo::db( if !is_service_default($connection) { validate_re($connection, - '^(sqlite|mysql(\+pymysql)?|postgresql|mongodb):\/\/(\S+:\S+@\S+\/\S+)?') + '^(sqlite|mysql(\+pymysql)?|postgresql(\+psycopg2)?|mongodb):\/\/(\S+:\S+@\S+\/\S+)?') if $manage_backend_package { case $connection { @@ -151,7 +151,7 @@ define oslo::db( $backend_package = false } } - /^postgresql:\/\//: { + /^postgresql(\+psycopg2)?:\/\//: { $backend_package = false require '::postgresql::lib::python' } diff --git a/releasenotes/notes/postgresql-590a36045748761a.yaml b/releasenotes/notes/postgresql-590a36045748761a.yaml new file mode 100644 index 0000000..7e771a4 --- /dev/null +++ b/releasenotes/notes/postgresql-590a36045748761a.yaml @@ -0,0 +1,5 @@ +--- +features: + - allow to specify a full dbname+drivername:// + protocol URL for postgresql databases. + diff --git a/spec/defines/oslo_db_spec.rb b/spec/defines/oslo_db_spec.rb index 2589f43..8f8b743 100644 --- a/spec/defines/oslo_db_spec.rb +++ b/spec/defines/oslo_db_spec.rb @@ -143,6 +143,14 @@ describe 'oslo::db' do end end + context 'with postgresql backend + drivername' do + let :params do + { :connection => 'postgresql+psycopg2://db:db@localhost/db' } + end + + it { is_expected.to contain_keystone_config('database/connection').with_value('postgresql+psycopg2://db:db@localhost/db').with_secret(true) } + end + context 'with incorrect database_connection string' do let :params do { :connection => 'foo://db:db@localhost/db', }