Does `commandbox-cfconfig`export database password...
# box-products
s
Does `commandbox-cfconfig`export database passwords as well? If yes, can they be omitted through a .env file?
t
yes in plain text for the first part for the second I am not sure about an env var but you can on the command line https://cfconfig.ortusbooks.com/using-the-cli/command-overview/export-settings
s
@thisOldDave thank you for your answer. I dug a bit deeper in the manual (as @Adam Cameron would suggest anyway before asking the question here first - sorry Adam). And I found a way to get things up & running without needing to store the password in the .cfconfig file (using .env).
😜 1
👍 1
a
Man. Didn't even get a chance to admonish you for not doing so first. "you snooze you lose", I guess.
😅 1
b
@satauros And did you see that CFConfig will actually swap out your passwords for you and auto-create the
.env
for you? https://cfconfig.ortusbooks.com/using-the-cli/command-overview/export-settings#json-expansion-replacements
So something like this
Copy code
cfconfig export to=.CFConfig.json replace:datasources\.(.*)\.password=DB_\1_PASSWORD
would automatically swap out all password fields and cram a matching env var named
DB_MYDSN_PASSWORD
into your
.env
file for you
You can configure those regex-based replacements at a global level as well so they are automatic every time you export.
s
@bdw429s I did not know that actually. I am now using the "automatic" way, being:
cfconfig_datasources_<datasourcename>_username
and
cfconfig_datasources_<datasourcename>_password
keys in my .env file
b
Yep, that's a great way to do it as well. Those values will basically be added on top of the existing config (env vars are loaded after the JSON is imported) so it's a handy way to just completely de-couple the two.
Just make sure on the latest CommandBox and CFConfig-- I made recent improvements to that stuff so it would work right.
👍 1