@@ -19,6 +19,7 @@ import (
19
19
20
20
"github.com/sirupsen/logrus"
21
21
22
+ platform_config "github.com/chef/automate/lib/platform/config"
22
23
"github.com/chef/automate/lib/secrets"
23
24
)
24
25
@@ -38,6 +39,11 @@ const (
38
39
tlsCrt = "/hab/svc/automate-cs-nginx/config/service.crt"
39
40
tlsKey = "/hab/svc/automate-cs-nginx/config/service.key"
40
41
tlsCA = "/hab/svc/automate-cs-nginx/config/root_ca.crt"
42
+ erchefSvcName = "automate-cs-oc-erchef"
43
+ erchefDBName = "automate-cs-oc-erchef"
44
+ bifrostSvcName = "automate-cs-oc-bifrost"
45
+ bifrostDBName = "automate-cs-oc-bifrost"
46
+ automateSvcPath = "/hab/svc/"
41
47
)
42
48
43
49
// These paths are injected at BUILD time based on our dependencies to
@@ -163,6 +169,36 @@ func (c passthrough) Run(args []string) error {
163
169
bifrostSuperuserID = string (bifrostSecData )
164
170
}
165
171
172
+ svcPath := automateSvcPath
173
+ // svc path can be overridden with SVC_PATH env variable in the format: "/hab/svc/"
174
+ if path := os .Getenv ("SVC_PATH" ); path != "" {
175
+ svcPath = path
176
+ }
177
+
178
+ erchefDB , err := platform_config .PGURIFromEnvironmentWithParams (erchefDBName , erchefSvcName , svcPath + erchefSvcName , "" )
179
+ if err != nil {
180
+ logrus .WithError (err ).Error ("could not create pg connection url for erchef" )
181
+ }
182
+ if erchefDB == "" {
183
+ erchefDB = erchefDBURI
184
+ }
185
+
186
+ bifrostDB , err := platform_config .PGURIFromEnvironmentWithParams (bifrostDBName , bifrostSvcName , svcPath + bifrostSvcName , "" )
187
+ if err != nil {
188
+ logrus .WithError (err ).Error ("could not create pg connection url for bifrost" )
189
+ }
190
+ if bifrostDB == "" {
191
+ bifrostDB = bifrostDBURI
192
+ }
193
+
194
+ // incase user wants to overide the uri
195
+ if erchefDBEnv := os .Getenv ("CSC_ERCHEF_DB_URI" ); erchefDBEnv != "" {
196
+ erchefDB = erchefDBEnv
197
+ }
198
+ if bifrostDBEnv := os .Getenv ("CSC_BIFROST_DB_URI" ); bifrostDBEnv != "" {
199
+ bifrostDB = bifrostDBEnv
200
+ }
201
+
166
202
// chef-server-ctl has been modified to take all necessary
167
203
// config via environment variables. All CSC_ variables are
168
204
// chef-server-ctl specific configuration.
@@ -171,8 +207,8 @@ func (c passthrough) Run(args []string) error {
171
207
fmt .Sprintf ("CSC_LB_URL=%s" , lbURL ),
172
208
fmt .Sprintf ("CSC_BIFROST_SUPERUSER_ID=%s" , bifrostSuperuserID ),
173
209
fmt .Sprintf ("CSC_BIFROST_URL=%s" , bifrostURL ),
174
- fmt .Sprintf ("CSC_BIFROST_DB_URI=%s" , bifrostDBURI ),
175
- fmt .Sprintf ("CSC_ERCHEF_DB_URI=%s" , erchefDBURI ),
210
+ fmt .Sprintf ("CSC_BIFROST_DB_URI=%s" , bifrostDB ),
211
+ fmt .Sprintf ("CSC_ERCHEF_DB_URI=%s" , erchefDB ),
176
212
fmt .Sprintf ("CSC_ERCHEF_REINDEX_SCRIPT=%s" , erchefReindexScript ),
177
213
fmt .Sprintf ("CSC_KNIFE_CONFIG_FILE=%s" , knifeConfigFile ),
178
214
fmt .Sprintf ("CSC_TLS_KEY=%s" , tlsKey ),
0 commit comments