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

Commit

Permalink
Adding support for SSL db parameters (#127). Also means updating sequ…
Browse files Browse the repository at this point in the history
…el to get access to the sslrootcert parameter
  • Loading branch information
hyandell committed Apr 25, 2018
1 parent dad92c5 commit bc6138d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ gem 'octokit', '~> 4.6'
gem 'libxslt-ruby', '> 0'
gem 'libxml-ruby', '> 0'
gem 'licensee', '~> 8.7'
gem 'sequel', '~> 4.6'
gem 'sequel', '~> 5.7'
gem 'pg'
20 changes: 18 additions & 2 deletions util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,24 @@ def get_db_handle(config)
server = ENV['DB_SERVER'] ? ENV['DB_SERVER'] : db_config[:server.to_s]
port = ENV['DB_PORT'] ? ENV['DB_PORT'] : db_config[:port.to_s]
database = ENV['DB_DATABSE'] ? ENV['DB_DATABSE'] : db_config[:database.to_s]
completeDBUrl = ENV['DATABASE_URL'] ? ENV['DATABASE_URL'] : sprintf('postgres://%s:%s@%s:%s/%s', user, password, server, port, database)
return Sequel.connect(completeDBUrl)

# Specific Postgresql options
sslmode = ENV['DB_SSLMODE'] ? ENV['DB_SSLMODE'] : db_config[:sslmode.to_s]
sslrootcert = ENV['DB_SSLROOTCERT'] ? ENV['DB_SSLROOTCERT'] : db_config[:sslrootcert.to_s]

#completeDBUrl = ENV['DATABASE_URL'] ? ENV['DATABASE_URL'] : sprintf('postgres://%s:%s@%s:%s/%s', user, password, server, port, database)
return Sequel.connect(
adapter: 'postgres',
host: server,
database: database,
user: user,
password: password,
port: port,
sslmode: sslmode,
sslrootcert: sslrootcert
)

#return Sequel.connect(completeDBUrl)
else
raise StandardError.new(sprintf('unsupported database engine[%s]', config[:engine]))
end
Expand Down

0 comments on commit bc6138d

Please sign in to comment.