-
Notifications
You must be signed in to change notification settings - Fork 50
/
postgres_config.erb.tmpl
100 lines (83 loc) · 2.85 KB
/
postgres_config.erb.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<%
require 'json'
postgres_host = p("postgresql.host", "")
postgres_port = p("postgresql.port", 0)
postgres_database = p("postgresql.database", "")
postgres_role_name = p("postgresql.role.name", "")
postgres_role_password = p("postgresql.role.password", "")
postgres_tls_enabled = p("postgresql.tls.enabled", false)
postgres_tls_skip_host_verify = false
postgres_tls_ca = ""
postgres_tls_public_cert = ""
postgres_tls_private_key = ""
if postgres_tls_enabled
postgres_tls_skip_host_verify = p("postgresql.tls.skip_host_verify", false)
postgres_tls_ca = p("postgresql.tls.cert.ca")
postgres_tls_public_cert = p("postgresql.tls.cert.certificate")
postgres_tls_private_key = p("postgresql.tls.cert.private_key")
end
if postgres_host.empty?
if_link("concourse_db") do |cdb|
postgres_host = cdb.p("postgresql.host", "")
end
if postgres_host.empty?
if_link("postgres") do |postgres|
postgres_host = postgres.instances.first.address
end
end
if postgres_host.empty?
raise "postgres.host not found through either properties or links"
end
end
if postgres_database.empty?
if_link("concourse_db") do |cdb|
postgres_database = cdb.p("postgresql.database", "")
end
if postgres_database.empty?
postgres_database = "atc"
end
end
if postgres_port.zero?
if_link("concourse_db") do |cdb|
postgres_port = cdb.p("postgresql.port", 0)
end
if postgres_port.zero?
if_link("postgres") do |postgres|
postgres_port = postgres.p("databases.port", 0)
end
end
if postgres_port.zero?
postgres_port = 5432
end
end
if postgres_role_name.empty?
if_link("concourse_db") do |cdb|
postgres_role_name = cdb.p("postgresql.role.name", "")
end
if postgres_role_name.empty?
raise "postgres.role.name not found through either properties or links"
end
end
if postgres_role_password.empty?
if_link("concourse_db") do |cdb|
postgres_role_password = cdb.p("postgresql.role.password", "")
end
if postgres_role_password.empty?
raise "postgres.role.password not found through either properties or links"
end
end
if_link("concourse_db") do |cdb|
postgres_tls_enabled = cdb.p("postgresql.sslmode", postgres_tls_enabled)
if postgres_tls_enabled
if postgres_tls_ca.empty?
postgres_tls_ca = cdb.p("postgresql.ca_cert.ca")
end
if postgres_tls_public_cert.empty?
postgres_tls_public_cert = cdb.p("postgresql.client_cert.certificate")
end
if postgres_tls_private_key.empty?
postgres_tls_private_key = cdb.p("postgresql.client_cert.private_key")
end
end
end
-%>