Skip to content

Get props from OS system environment, just like OBP API #59

Open

Description

@chrisjsimpson

Objective:

(The same as OBP API OpenBankProject/OBP-API#1208 )

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:
    • oauth_1.hostname becomes OAUTH_1_HOSTNAME
    • api_hostname becomes API_HOSTNAME

Activity

  1. added a commit that references this issue on Feb 14, 2019
  2. added a commit that references this issue on Feb 22, 2019
    e360b20
  3. chrisjsimpson commented on Feb 22, 2019

    @chrisjsimpson
    ContributorAuthor

    Oh damn @hongwei1 I didn't see your commit 😆 damn, thank you! We had the same ideas.

    At least I got a chance to learn some Scala!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions