question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default value for missing environment variables in yaml and ini config files

See original GitHub issue

How could I specify a default value for the missing environment variable in the configuration provider?

For example: pseudo code

config = dependency_injector.providers.Configuration()
config.from_yaml("conf.yml")

print(config.some_key.size)  -> will print ${SOME_KEY_SIZE} if envvar is missing

conf file

some_key:
     size: ${SOME_KEY_SIZE}

or maybe we could leave such cases with empty/none values? for e.g.

config.some_key.size  -> will be None

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rmk135commented, Jun 11, 2021

Well, yeah, I agree. I think I can implement it.

1reaction
rmk135commented, Jun 7, 2021

Hi @hbmshemet. Yeah, reasonable concern. I’ll check what’s going on in the code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use environment variables in the configuration - Elastic
Each variable reference is replaced at startup by the value of the environment variable. The replacement is case-sensitive and occurs before the YAML...
Read more >
Python, application configuration : environment variables, ini ...
In this chapter, how to read (write) configuration data with Python from environment variables, INI files with configparser and YAML files ...
Read more >
Using Environment Variables in Python for App Configuration ...
Learn how experienced developers use environment variables in Python, including managing default values and typecasting.
Read more >
Load config from file & environment variables in Golang with ...
It can find, load, and unmarshal values from a config file. It supports many types of files, such as JSON, TOML, YAML, ENV,...
Read more >
Settings and Environment Variables - FastAPI
If not provided, it's None by default, here we provide "World" as the default value to use. Then you could call that Python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found