OpenBankProject / API-Explorer

API Explorer for OBP API. A Scala / Liftweb application that consumes the OBP-API resource documentation so that developers can browse and interact with the OBP REST API enpoints.
30 stars 55 forks source link

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

Open chrisjsimpson opened 5 years ago

chrisjsimpson commented 5 years ago

Objective:

(The same as OBP API https://github.com/OpenBankProject/OBP-API/issues/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: https://github.com/chrisjsimpson/obp-kubernetes/issues/2#issuecomment-460495439 (<< 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

chrisjsimpson commented 5 years ago

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

At least I got a chance to learn some Scala!