-
Notifications
You must be signed in to change notification settings - Fork 426
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
fix(envier): support multiple sources #12535
Draft
mabdinur
wants to merge
2
commits into
munir/bump-lib-datadog
Choose a base branch
from
munir/support-stable-config-in-envier
base: munir/bump-lib-datadog
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+128
−114
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,10 +1,13 @@ | ||||||
import os | ||||||
from typing import Any # noqa:F401 | ||||||
from typing import Callable # noqa:F401 | ||||||
from typing import Dict # noqa:F401 | ||||||
from typing import List # noqa:F401 | ||||||
from typing import Optional # noqa:F401 | ||||||
from typing import Union # noqa:F401 | ||||||
|
||||||
from envier import Env | ||||||
|
||||||
from ddtrace.internal.native import get_configuration_from_disk | ||||||
|
||||||
from ._otel_remapper import parse_otel_env | ||||||
|
@@ -13,6 +16,17 @@ | |||||
FLEET_CONFIG, LOCAL_CONFIG = get_configuration_from_disk() | ||||||
|
||||||
|
||||||
class EnvDD(Env): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"""Provides support for configuration values from the environment variables and Static files""" | ||||||
|
||||||
def __init__(self) -> None: | ||||||
self.fleet_source = FLEET_CONFIG.copy() | ||||||
self.local_source = LOCAL_CONFIG.copy() | ||||||
# Order of precedence: local stable config < environment variables < managed stable config | ||||||
source = {**self.local_source, **os.environ.copy(), **self.local_source} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Why do we need copies here? |
||||||
super().__init__(source=source, parent=None, dynamic=None) | ||||||
|
||||||
|
||||||
def get_config( | ||||||
envs: Union[str, List[str]], | ||||||
default: Any = None, | ||||||
|
@@ -37,7 +51,7 @@ def get_config( | |||||
if env in FLEET_CONFIG: | ||||||
source = "fleet_stable_config" | ||||||
effective_env = env | ||||||
val = FLEET_CONFIG[env]["value"] | ||||||
val = FLEET_CONFIG[env] | ||||||
break | ||||||
# Get configurations from datadog env vars | ||||||
if val is None: | ||||||
|
@@ -61,7 +75,7 @@ def get_config( | |||||
if env in LOCAL_CONFIG: | ||||||
source = "local_stable_config" | ||||||
effective_env = env | ||||||
val = LOCAL_CONFIG[env]["value"] | ||||||
val = LOCAL_CONFIG[env] | ||||||
break | ||||||
# Convert the raw value to expected format, if a modifier is provided | ||||||
if val is not None and modifier: | ||||||
|
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 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 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 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
?