Skip to content

Commit dea9ab7

Browse files
committed
Use PGSSLMODE=disable for now
1 parent b5c46a7 commit dea9ab7

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/pkg/
77
/spec/reports/
88
/tmp/
9+
/Gemfile.lock

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## v0.2.0
2+
3+
- Use `PGSSLMODE=disable` for psqldef for now
4+
5+
## v0.1.0
6+
7+
- Initial release

lib/sqldef.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ module Sqldef
2424
]
2525
private_constant :COMMANDS
2626

27+
ENVS = {
28+
'psqldef' => { 'PGSSLMODE' => 'disable' }, # TODO: support updating this
29+
}
30+
private_constant :ENVS
31+
2732
@bin = Dir.pwd
2833

2934
class << self
@@ -35,7 +40,7 @@ def export(command:, path:, host:, port: nil, user:, password: nil, database:)
3540
sqldef = download(command)
3641
schema = IO.popen(
3742
[
38-
sqldef,
43+
env(command), sqldef,
3944
"--user=#{user}", *(["--password=#{password}"] if password),
4045
"--host=#{host}", *(["--port=#{port}"] if port),
4146
'--export', database,
@@ -51,7 +56,7 @@ def export(command:, path:, host:, port: nil, user:, password: nil, database:)
5156
def dry_run(command:, path:, host:, port: nil, user:, password: nil, database:)
5257
sqldef = download(command)
5358
execute(
54-
sqldef,
59+
env(command), sqldef,
5560
"--user=#{user}", *(["--password=#{password}"] if password),
5661
"--host=#{host}", *(["--port=#{port}"] if port),
5762
'--dry-run', database,
@@ -64,7 +69,7 @@ def dry_run(command:, path:, host:, port: nil, user:, password: nil, database:)
6469
def apply(command:, path:, host:, port: nil, user:, password: nil, database:)
6570
sqldef = download(command)
6671
execute(
67-
sqldef,
72+
env(command), sqldef,
6873
"--user=#{user}", *(["--password=#{password}"] if password),
6974
"--host=#{host}", *(["--port=#{port}"] if port),
7075
database,
@@ -104,6 +109,10 @@ def execute(*cmd, **opts)
104109
end
105110
end
106111

112+
def env(command)
113+
ENVS.fetch(command.to_s, {})
114+
end
115+
107116
def build_url(command)
108117
unless COMMANDS.include?(command)
109118
raise "Unexpected sqldef command: #{command}"

0 commit comments

Comments
 (0)