The inability to pass in objects via ENV vars was caused by the fact that when we parse the SB_* environment values based on their type as specified in the config.schema.json; however, we don't specifically handle the object type so it is run through the catch-all safe_echo code:
However, if we permit configurations of type "object" to encoded directly into the JSON via the object() function in the bash script, we can use them as standard configuration.
How you can test this
Before
On the main branch:
Build docker image: docker build -t stac-browser
Run docker image with auth config set as environment variable: docker run -it -e SB_authConfig='{"foo": "bar"}' --name stac-browser stac-browser
In another terminal, review the generated config: docker exec stac-browser cat /usr/share/nginx/html/config.js
You should see an object where the authConfig property is a string rather than an object:
@m-mohr Ah, I had missed those details. Thanks for pointing out that this is documented and intended behavior. In 408ed94 and 88212c8 I've removed such documentation in hopes that we can indeed adjust this beavior.
(Seeing that this PR is not a trivial one-liner as I had initially hoped, I've updated the description in hopes of adding more clarity to what is being changed and why)
What I'm changing
If a config value is an object, the tooling to convert it from an environment var to JS will keep it as a string (see #460).
This PR will instead retain its state as a JSON object.
This will allow the following configurations to be correctly set via environment variables:
How I did it
The inability to pass in objects via ENV vars was caused by the fact that when we parse the
SB_*
environment values based on their type as specified in theconfig.schema.json
; however, we don't specifically handle theobject
type so it is run through the catch-allsafe_echo
code:https://github.com/radiantearth/stac-browser/blob/108947ebe8cbd64c7e288bbaa3c5f81293706d3e/config.schema.json#L225-L236
https://github.com/radiantearth/stac-browser/blob/108947ebe8cbd64c7e288bbaa3c5f81293706d3e/docker/docker-entrypoint.sh#L58-L92
This keeps it as a string: https://github.com/radiantearth/stac-browser/blob/108947ebe8cbd64c7e288bbaa3c5f81293706d3e/docker/docker-entrypoint.sh#L1-L2
However, if we permit configurations of type "object" to encoded directly into the JSON via the
object()
function in the bash script, we can use them as standard configuration.How you can test this
Before
On the
main
branch:docker build -t stac-browser
docker run -it -e SB_authConfig='{"foo": "bar"}' --name stac-browser stac-browser
docker exec stac-browser cat /usr/share/nginx/html/config.js
You should see an object where the
authConfig
property is a string rather than an object:After
Following the above steps on this branch, you should see now see an object where the
authConfig
property is an object:closes #460