OpenBankProject / OpenBankProject/OBP-API

Get props from OS system environment

Open
#1,208 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.7k
Forks
482
Avg merge
1d 12h
Merged PRs (30d)
15

Description

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: 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

  • 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the property-loading implementation and the getPropsValue entry point described in the issue, then review how the existing props-file lookup works. Check how sys.env is accessed in the project and verify that normalized environment names take precedence while missing values fall back to the props file.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.