Skip to content

HowToSetConfigValuesFromTheOutside

Carlo Barazzetta edited this page Jan 20, 2017 · 1 revision

How to set config and metadata values from external files

When working in a team, it is customary that database names, user names and passwords and other data are different for each developer or development machine. Since these data is usually stored in the application Config.yaml file, this prevents to put the file under version control unless each developer keeps its own different copy, which is a burden to maintain.

You can do that through environment variables, which you can embed into any metadata file just by surrounding them with % characters, or you can do in a more local way by moving the data to separate files.

The %FILE()% macro

One of the uses of Kitto's %FILE()% macro (there can be many others) is to allow you to hold personal data outside Config.yaml and into local files that are never put under version control. Example:

Databases:
  Main: DBX
    Connection:
      DriverName: MSSQL
      HostName: %FILE(%HOME_PATH%.dbhostname.local)%
      DataBase: %FILE(%HOME_PATH%.dbname.local)%
      OS Authentication: True             

Just create local files named .dbhostname.local and .dbname.local, put the host/instance name in the former and the catalog name in the latter, and make sure those files are ignored by your version control system.
When processing the %FILE()% macro, Kitto will expand the file name, load and expand again the file contents (meaning that both name and contents may contain other macros).

Another example:

Auth: DB
  Defaults:
    UserName: %FILE(%HOME_PATH%.username.local)%
    Password: %FILE(%HOME_PATH%.password.local)%

For more details, see the Macros page.

Clone this wiki locally