-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3036 from bitzesty/env-var-changes
chore: ENV var changes for new platform
- Loading branch information
Showing
5 changed files
with
31 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module CredentialsResolver | ||
module_function | ||
|
||
def redis_uri | ||
ENV["REDIS_ENDPOINT"].presence || JSON.parse(ENV["VCAP_SERVICES"])["redis"][0]["credentials"]["uri"] | ||
rescue | ||
ENV["REDIS_URL"] | ||
end | ||
|
||
def pgsql_uri | ||
if ENV["DATABASE_CREDENTIALS"].present? | ||
parse_database_config(ENV["DATABASE_CREDENTIALS"]) | ||
else | ||
# Fallback to the original logic | ||
JSON.parse(ENV["VCAP_SERVICES"])["postgres"][0]["credentials"]["uri"] | ||
end | ||
rescue | ||
ENV["DATABASE_URL"] | ||
end | ||
|
||
def parse_database_config(config_json) | ||
config = JSON.parse(config_json) | ||
|
||
# Construct the database URI | ||
"#{config["engine"]}://#{config["username"]}:#{config["password"]}@#{config["host"]}:#{config["port"]}/#{config["dbname"]}" | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.