-
Notifications
You must be signed in to change notification settings - Fork 39
Enable overriding environment detection #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Minor comments.
@@ -32,6 +37,19 @@ async def resolve_environment() -> Environment: | |||
log.debug("Environment resolved from cache.") | |||
return EnvironmentCache.environment | |||
|
|||
print(repr(Config.environment)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove please or use the logger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
if Config.environment: | ||
if Config.environment.lower() == "lambda": | ||
EnvironmentCache.environment = lambda_environment | ||
elif Config.environment.lower() == "ec2": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're calling .lower()
multiple times which will result in unnecessary string allocation. Can we just do this once at the top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed -- good call
Sometimes it would be great to override the default selected environment (e.g. to force usage of the Lambda environment outside of Lambda), which this change enables. The code is based on #26.
PR Code Suggestions ✨
|
Sometimes it would be great to override the default selected environment (e.g. to force usage of the Lambda environment outside of Lambda), which this change enables.
The code is based on #26.
Issue #, if available:
Description of changes:
This adds a new configuration setting that allows overriding/bypassing the environment detection. In practice this, for example, can be useful when looking to use the library in a lambda-like setting but without the classical env variables.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.