Inheriting environments
A particularly useful use case for environments is inheritance, the ability to define one base environment with many of the overrides in place so environments like: development, production, or stage can easily be set up without needing to repeat entries many times.
One of the most common use cases for this is having different addresses for the AD target depending on the environment you have loaded. For this example company-base.json will be used as the base environment, and both company-dev.json and company-prod.json that inherit from it.
Using a Data.hid_target_ad component override as an example again, the company-base.json file is written as:
{ "Scenario": {}, "Functional": {}, "Data": { "hid_target_ad": { "ad.json": { "Fields": { "address": "{server=${_vars.ad.address};listNestedGrps=true}" } } } } }
Then, other environment files are written similar to this company-dev.json file:
{ "_inherit" : ["company-base"], "_vars": { "ad": { "address": "development-address.domain" } } }
or this company-prod.json :
{ "_inherit" : ["company-base"], "_vars": { "ad": { "address": "production-address.domain" } } }
This would make it so the replacement in the AD target address line depends on which of the two environment files (dev or prod) is loaded, without explicitly overriding the address in both environments. Note that writing your environments like this will make it so company-base.json cannot function independently, which is fine as long as it’s understood in your implementation.