Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit bc6138d

Browse files
committed
Adding support for SSL db parameters (#127). Also means updating sequel to get access to the sslrootcert parameter
1 parent dad92c5 commit bc6138d

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ gem 'octokit', '~> 4.6'
88
gem 'libxslt-ruby', '> 0'
99
gem 'libxml-ruby', '> 0'
1010
gem 'licensee', '~> 8.7'
11-
gem 'sequel', '~> 4.6'
11+
gem 'sequel', '~> 5.7'
1212
gem 'pg'

util.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,24 @@ def get_db_handle(config)
2828
server = ENV['DB_SERVER'] ? ENV['DB_SERVER'] : db_config[:server.to_s]
2929
port = ENV['DB_PORT'] ? ENV['DB_PORT'] : db_config[:port.to_s]
3030
database = ENV['DB_DATABSE'] ? ENV['DB_DATABSE'] : db_config[:database.to_s]
31-
completeDBUrl = ENV['DATABASE_URL'] ? ENV['DATABASE_URL'] : sprintf('postgres://%s:%s@%s:%s/%s', user, password, server, port, database)
32-
return Sequel.connect(completeDBUrl)
31+
32+
# Specific Postgresql options
33+
sslmode = ENV['DB_SSLMODE'] ? ENV['DB_SSLMODE'] : db_config[:sslmode.to_s]
34+
sslrootcert = ENV['DB_SSLROOTCERT'] ? ENV['DB_SSLROOTCERT'] : db_config[:sslrootcert.to_s]
35+
36+
#completeDBUrl = ENV['DATABASE_URL'] ? ENV['DATABASE_URL'] : sprintf('postgres://%s:%s@%s:%s/%s', user, password, server, port, database)
37+
return Sequel.connect(
38+
adapter: 'postgres',
39+
host: server,
40+
database: database,
41+
user: user,
42+
password: password,
43+
port: port,
44+
sslmode: sslmode,
45+
sslrootcert: sslrootcert
46+
)
47+
48+
#return Sequel.connect(completeDBUrl)
3349
else
3450
raise StandardError.new(sprintf('unsupported database engine[%s]', config[:engine]))
3551
end

0 commit comments

Comments
 (0)