This repository has been archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Dynamically load environment variables when using BootstrapFromDocker #60
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This test implies that you can send through '[]' but no other tests validate that behavior. Additionally, the current bootstrap process will create a value for this hocon key as '[[]]' which is incorrect.
Some cases may require us to specify the hostname on startup (ie. multiple NICs). And, the previous code would have blocked environment variables from overriding the value. So, moving it lower into the fallback block.
@Aaronontheweb Can I get a review on this to help close out petabridge/lighthouse#115 |
Aaronontheweb
approved these changes
Dec 31, 2019
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.
Looks great!
@@ -84,5 +83,27 @@ public void ShouldStartNormallyIfNotEnvironmentVariablesAreSupplied() | |||
myConfig.GetString("akka.remote.dot-netty.tcp.public-hostname").Should().Be(Dns.GetHostName()); | |||
myConfig.HasPath("akka.remote.dot-netty.tcp.port").Should().BeFalse(); | |||
} | |||
|
|||
[Fact] | |||
public void ShouldStartIfValidAkkaConfigurationSuppliedByEnvironmentVariables() |
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.
LGTM
Aaronontheweb
added a commit
that referenced
this pull request
Dec 31, 2019
…#60) * Remove faulty test. This test implies that you can send through '[]' but no other tests validate that behavior. Additionally, the current bootstrap process will create a value for this hocon key as '[[]]' which is incorrect. * Add environment variable configuration loader * Use environment variable configuration loader in docker bootstrap * Fix formatting issue when writing entries to hocon * Add unit test to validate envvar loading * Move default hostname into fallback Some cases may require us to specify the hostname on startup (ie. multiple NICs). And, the previous code would have blocked environment variables from overriding the value. So, moving it lower into the fallback block. Co-authored-by: Aaron Stannard <aaron@petabridge.com>
ghost
deleted the
feat/envvar-loader
branch
January 11, 2020 03:05
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, I'm doing this to allow us to more easily configure Lighthouse while it's running in a Docker container. (See, petabridge/lighthouse#115). The quick and dirty method would have been to simply carry on with hard coding the environment variable extraction as in the previous version. But I can see the need to configure more and more settings from envvars and it will begin to get tedious at some point. So I've created this small set of classes as a step towards extending the core Akka.NET configuration libraries to support loading from environment variables.
With that in mind, there are a few things that should be noted:
I feel this method could be better named (eg.
config.FromEnvironment()
), but as I've noted there is a possibility of moving this code to the core Akka.NET libraries. So, I'm keeping the name as-is to avoid potential clashes in the future.Because everything happens a bit more dynamically, the logging and output of configuration values to the console has been removed. I think this isn't too bad considering one can easily turn on the Akka.NET feature that prints config on startup.
One unit test has been removed where seed nodes where checked against a variable of '[]'. See the respective commit message for more details.
Once this is merged, we can bump the dependency in Lighthouse and start working on the default resolver strategy.