geopython / pygeoapi

pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.
https://pygeoapi.io
MIT License
501 stars 265 forks source link

Allow providing a default value in config when env variable does not exist #1600

Closed ricardogsilva closed 7 months ago

ricardogsilva commented 8 months ago

It would be useful if the pygeoapi config file would allow defining a default value for when an environment variable is not defined.

Something like:

        ...
        providers:
            - type: feature
              name: Elasticsearch
              data: ${ELASTICSEARCH_SERVER_URL:-http://localhost:9200}/canada-hydat-daily-mean-02hc003
              id_field: IDENTIFIER
              time_field: DATE

In the snippet above, pygeoapi would try to load the ELASTICSEARCH_SERVER_URL variable from the environment and in case this variable would not exist, then a default value of http://localhost:9200 would be used.

Additional context This feature would be useful for me to be able to run, for example the CITE tests in a docker compose stack without having to modify the existing CITE related config file that is present in the tests

I would be willing to provide an implementation for this in a PR if this is deemed a suitable addition

tomkralidis commented 8 months ago

Makes sense @ricardogsilva, and +1 for a PR (looks like an update to pygeoapi.util.yaml_load would do the trick).