GithubHelp home page GithubHelp logo

config-mapper's Introduction

config-mapper

This repository is to maintain the codes that used to project single toml file configurations into WSO2 products specific configurations.

Phases

Parsing

Read the config from the TOML based configuration file which will be the single source of truth for all the product configuration. No processing is done on this phase and whatever the configs read will be passed to the next phase

Mapping

Responsible for mapping the product configuration keys to the keys used by component level. This should be a 1:1 mapping. If there are 1:n mappings from TOML to product configs, need to use Inferring to get it done.

Mapping is done using the file named “key-mappings.json”. The format of that file is as below,

{

 "key_from_toml_file": "key_used_by_component"

}

Inferring

Responsible for inferring configuration values, based on other configuration that the user has already provided in the configuration source.

Eg.

  • If the user specifies the database is ‘mysql’, we can infer the driver class, validation query and connection URL (assuming he has already provided host,port,db name etc)
  • If the user specifies the userstore as ‘readwriteldap’, there are several LDAP related connection properties we can pre-populate with defaults.

Defaults

Responsible for providing the default values for the configurations. These values will be taken only if the user has not provided the configuration value or it has not been inferred in the previous phrase.

Resolve Placeholders

Responsible for replacing placeholders that are given in the configuration values. The placeholders can be used to resolve environment variables, system properties or any other configuration value from the pipeline. Please refer the following subsection on how to use placeholders.

Resolve Units

Responsible for resolving the units from human readable/understandable unit to component accepted unit. For example, at the component level “foo_timeout” may accept milliseconds. However, by default, we want to set it to 1 minute. That means we need to do some math and set it to 1601000, Which is 60000. The drawbacks are,

  • User need to know what units are expected
  • Need to do the math and give the value in expected unit
  • May get to misconfigure due to inconsistent unit usages. (There are configs that use ms, seconds, minutes. Therefore the user may assume the same unit for two configs)

To overcome this problem, this phrase of the pipeline convert the units from the user given unit to component expected units. The user only needs to suffix the unit to the value when configuring. Eg. In the above case, the user may give either of,

“foo_timeout = 1m” or “foo_timeout = 60s”

Validation

Responsible for context-aware validation of the configuration values and show any errors in case there are validation failures. This can be used to mandate certain configuration and make sure the values match provided regular expression.

Dependent versions

  • com.fasterxml.jackson.core:jackson-annotations:jar:2.7.0
  • com.fasterxml.jackson.core:jackson-core:jar:2.7.9
  • com.fasterxml.jackson.core:jackson-databind:jar:2.7.9.1
  • com.google.guava:guava:jar:22.0
  • com.google.re2j:re2j:jar:1.2
  • com.hubspot.jinjava:jinjava:jar:2.4.14
  • org.xmlunit:xmlunit-core:jar:2.6.2
  • org.xmlunit:xmlunit-matchers:jar:2.6.2
  • org.xmlunit:xmlunit-assertj:jar:2.6.2
  • net.consensys.cava:cava-toml:jar:0.5.0

config-mapper's People

Contributors

chanikag avatar emswbandara avatar gayashanbc avatar madushadhanushka avatar maheshika avatar nirothipan avatar pulasthi7 avatar sanduninagahage avatar sdkottegoda avatar senthalan avatar tharindu1st avatar vathsan avatar wso2-jenkins-bot avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.