Skip to content

Allow loading config vars from env#137

Merged
jacomago merged 9 commits intoChannelFinder:masterfrom
jacomago:env-read
Mar 20, 2026
Merged

Allow loading config vars from env#137
jacomago merged 9 commits intoChannelFinder:masterfrom
jacomago:env-read

Conversation

@jacomago
Copy link
Contributor

This allows overriding the configuration files by reading from the environment any config vars prefixed with RECCEIVER_

This allows overriding the configuration files by reading from the environment any config vars prefixed with RECCEIVER_
The healthcheck is not working on channelfinder since 5.0.0
Comment on lines +53 to 55
result = self.get(key)
if result is None:
raise KeyError("No option value")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just do return self[key] (or is that ValueError?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is ConfigParser.NoOptionError

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you did dict[key] access with try-except you can get exception chaining, but not sure if that's better or not. Your call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think self is not a dictionary. I think it is a wrapper around ConfigParser. I think you have to use get.

Copy link
Contributor

@anderslindho anderslindho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the ordering a bit strange here, that env vars - which are implicitly read - are prioritised over a config file?

@jacomago
Copy link
Contributor Author

Isn't the ordering a bit strange here, that env vars - which are implicitly read - are prioritised over a config file?

Its the same hierachy as spring-boot https://docs.spring.io/spring-boot/reference/features/external-config.html

For whatever reason no log on init
Guessing the logger hasn't setup at this point.
Set to all uppercase so clear it is an env variable
@sonarqubecloud
Copy link

@jacomago jacomago merged commit 048c286 into ChannelFinder:master Mar 20, 2026
12 of 13 checks passed
@jacomago jacomago deleted the env-read branch March 20, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants