-
Notifications
You must be signed in to change notification settings - Fork 3
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
Allow usage of environment variables in rules path #608
base: main
Are you sure you want to change the base?
Conversation
…True) based on list of prefixes (default QDT_*, QGIS_*)
Quality Gate passedIssues Measures |
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #608 +/- ##
==========================================
- Coverage 70.63% 70.47% -0.16%
==========================================
Files 47 47
Lines 3204 3214 +10
Branches 566 567 +1
==========================================
+ Hits 2263 2265 +2
- Misses 740 746 +6
- Partials 201 203 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -14,6 +14,7 @@ | |||
# Standard library | |||
import json | |||
import logging | |||
import os |
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.
Prefer complete function import rather than package. See other projects modules where we work with env vars to make it consistent with.
only_prefixed_variables: bool = True, | ||
variables_prefix: list[str] = ["QDT_", "QGIS_"], | ||
) -> None: | ||
self.only_prefixed_variables = only_prefixed_variables |
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.
Docstring is missing
Returns: | ||
dict: dict with environment variables to use in rules. | ||
""" | ||
env_vars = dict(os.environ) |
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.
It's already a mapping object no?
Hi @nicogodet, We're pretty interested in your feature. @jmkerloch do you want to have a look? |
I would really like to have control over this settings in scenario.yml. |
After discussion with @Guts on IRC, this PR intends to allow usage of environment variables in rules path.
profile.json
QdtRulesContext is modified :
_context_env
to return environment variables as dictonly_prefixed_variables
boolean to control behavior of_context_env
if it should return all variables or only filtered based on prefixes (default to True)variables_prefix
a list with allowed prefixesTODO:
Control
only_prefixed_variables
andvariables_prefix
with 2 environment variablesQDT_RULES_ONLY_PREFIXED_VARIABLES
andQDT_RULES_VARIABLES_PREFIXES
--> Easy and can be implemented in generic job classControl
only_prefixed_variables
andvariables_prefix
in scenario.yml --> not trivial to me as other jobs need QdtRulesContext and default QdtRulesContext initialized in generic job will not contains alteredonly_prefixed_variables
andvariables_prefix
Tests
Documentation