Support LicenseKey via environment variable fallback#4634
Conversation
LicenseKey now falls back to the AUTOMAPPER_LICENSE_KEY environment variable if not explicitly set. Added comprehensive unit and integration tests to verify this behavior. Updated test project dependencies to support DI and logging in tests.
|
@jbogard can you run this pipeline to check if anything goes wrong |
|
Hi @jbogard, is this issue related to pipeline, am I missing something? |
|
Hmm that is odd, I tried to re-run it but still getting that error. |
|
yeah @jbogard thats strange does it have something to do with ci pipeline and about read and write permissions? |
|
Hi @jbogard I see you changed the permission into your release.yml and maybe same has to be done from ci.yml from read to write for this to complete as mentioned in my previous comment, and you can try firing the pipeline to verify. Thanks |
|
This would be a great relief if we have this directly fed from the configuration, and introduce less noise ... as we are having more than dozens of services which is using automapper and we just acquired the enterprise license. We are looking for best option weather to go with per service configuration v/s one-place shared library. Both holds its own pros and cons, but if we get this env. var auto-discovery, it would be the real winner for us... with minimal changes. Waiting for this and any other valuable suggestions!!! |
PR: Auto-Detect License Key from Environment Variables Fixes #4631
What Changed
Added support for reading the AutoMapper license key from an environment variable instead of requiring manual configuration in code.
Why
In containerized and cloud environments, it's better to use environment variables for sensitive configuration instead of hardcoding values in code.
How It Works
The LicenseKey property now checks for values in this order:
Usage
NEW WAY - Using Environment Variable:
Set environment variable AUTOMAPPER_LICENSE_KEY before running your app
Then just add AutoMapper without setting the license key:
OLD WAY - Still Works (Backward Compatible):
BOTH SET - Code value wins:
If you set both the environment variable AND code value, the code value is used.
Tests Added
Backward Compatibility
100% backward compatible. All existing code continues to work exactly the same way.