Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get props from OS system environment #1208

Open
chrisjsimpson opened this issue Feb 5, 2019 · 1 comment
Open

Get props from OS system environment #1208

chrisjsimpson opened this issue Feb 5, 2019 · 1 comment

Comments

@chrisjsimpson
Copy link
Contributor

Objective:

Make container-like deployments easier by reading props from sys.env, we want to avoid rewriting the props file and repacking the war file like this: chrisjsimpson/obp-kubernetes#2 (comment) (<< this is to be avoided)

For docker-like environments, it is helpful instead to read runtime settings from the operating system environment vars, because we can inject these at container runtime.

pseudo Logic

pseudo code

  def getPropsValue(nameOfProperty: String): Box[String] = {
    # Replace "." with "_" (environment vars cannot include ".")
    brandSpecificPropertyName = brandSpecificPropertyName.replace('.', '_')
    # Convert to upper case
    brandSpecificPropertyName = brandSpecificPropertyName.toUpperCase()
    if (sys.env.get(brandSpecificPropertyName)) {
      
    } else {
      ..... load from props file as normal
    }
  }

Gotcha

  • Environment variables will be upper case (s.toUpperCase())
  • Environment variables cannot contain a dot ("."), therefore:
    • db.url becomes DB_URL
    • kafka.user.authentication becomes KAFKA_USER_AUTHENTICATION
@chrisjsimpson
Copy link
Contributor Author

hongwei1 added a commit to hongwei1/OBP-API that referenced this issue Feb 6, 2019
chrisjsimpson added a commit to chrisjsimpson/obp-kubernetes that referenced this issue Feb 7, 2019
simonredfern added a commit that referenced this issue Feb 7, 2019
#1208 Get props from OS system environment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant