Hey all,
I am trying to use environment variables to setup certain configurations -
{
"getAPIEndPoint": "$[env:ENDPOINT_Sys;default=/public/dev4/v1/store/store]",
}
This I know if allowed but is it possible to reference the environment variable directly in any OSGi configuration as shown below -
Here the api_env is an environment variable but not tied to any OSGi configuration - Is it allowed to use this environment variable directly on the fly?
{
"getAPIEndPoint": "/public/$[env:api_env;default=dev4]/v1/category/api/v1/categories",
}
As per https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager-forms/how-to-access-enviro... we need to establish an OSGi configuration if we want to use an environment variable as part of another java osgi service.
thanks,
Solved! Go to Solution.
Views
Replies
Total Likes
@NageshRaja - It will work as part of the string too.
{
"getAPIEndPoint": "/public/$[env:api_env;default=dev4]/v1/category/api/v1/categories",
}
Assuming your api_env has value 123 set in environment variable it will set the config as - /public/123/v1/category/api/v1/categories else it will be DEFAULT - /public/dev4/v1/category/api/v1/categories
Hope this helps!
Hi @NageshRaja,
I believe you can use Environment variables directly in your code without having them included in the OSGi configuration. I haven't tried it myself, but the Java API: System.getenv("YOUR_ENV_VARIABLE") should work normally.
Good luck,
Daniel
yeah I don't want to actually change any code if possible was hoping this too work directly! thanks for the response!
Views
Replies
Total Likes
@NageshRaja - It will work as part of the string too.
{
"getAPIEndPoint": "/public/$[env:api_env;default=dev4]/v1/category/api/v1/categories",
}
Assuming your api_env has value 123 set in environment variable it will set the config as - /public/123/v1/category/api/v1/categories else it will be DEFAULT - /public/dev4/v1/category/api/v1/categories
Hope this helps!
thanks for the confirmation mate! kudos!
Views
Replies
Total Likes
Hi @NageshRaja
Please check below article for how to use environment variable with OSGI
thanks arun i did check but was not sure whether it would work as part of string too!
Views
Replies
Total Likes
hi @NageshRaja
I believe that Cloud evaluates your configs and wherever it finds placeholders like $[secret:SECRET_VAR_NAME] or $[env:ENV_VAR_NAME] it replaces them with the var values (if there are any), or replaces them with the default values (if any were provided) or it replaces them with nothing (I believe you'll have an empty string).
But this is really simple to test out. Just add some configs and see how things behave (learning through empirical)
hey @Tethich, we still don't have access to the cloud so just preparing the code migration changes which will come up hence the reason for asking!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Like
Replies