Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Unified Diff: recipe_engine/recipe_api.py

Issue 2933473002: [context] Split "env" values and prefixes. (Closed)
Patch Set: comments, tests, better definition Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | recipe_engine/step_runner.py » ('j') | recipe_modules/context/tests/env.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/recipe_api.py
diff --git a/recipe_engine/recipe_api.py b/recipe_engine/recipe_api.py
index 6ec91c3137bcfc74aa533b73cbc9083ce8df6773..b2e231f342cd42cf78d79841ff310e23783904cf 100644
--- a/recipe_engine/recipe_api.py
+++ b/recipe_engine/recipe_api.py
@@ -257,9 +257,9 @@ class TriggerSpec(_TriggerSpec):
_StepConfig = collections.namedtuple('_StepConfig',
- ('name', 'base_name', 'cmd', 'cwd', 'env', 'allow_subannotations',
- 'trigger_specs', 'timeout', 'infra_step', 'stdout', 'stderr', 'stdin',
- 'ok_ret', 'step_test_data', 'nest_level'))
+ ('name', 'base_name', 'cmd', 'cwd', 'env_prefixes', 'env',
+ 'allow_subannotations', 'trigger_specs', 'timeout', 'infra_step', 'stdout',
+ 'stderr', 'stdin', 'ok_ret', 'step_test_data', 'nest_level'))
class StepConfig(_StepConfig):
"""
@@ -277,6 +277,16 @@ class StepConfig(_StepConfig):
"delete_this": None,
"static_value": "something",
}
+
+ The optional "env_prefix" parameter contains values that, if specified, will
+ transform an environment variable into a "pathsep"-delimited sequence of
+ items:
+ - If an environment variable is also specified for this key, it will be
+ appended as the last element: <prefix0>:...:<prefixN>:ENV
+ - If no enviornment variable is specified, the current environment's value
+ will be appended, unless it's empty: <prefix0>:...:<prefixN>[:ENV]?
+ - If an enviornment variable with a value of None (delete) is specified,
+ nothing will be appeneded: <prefix0>:...:<prefixN>
"""
_RENDER_WHITELIST=frozenset((
@@ -291,10 +301,11 @@ class StepConfig(_StepConfig):
))
@classmethod
- def create(cls, name, base_name=None, cmd=None, cwd=None, env=None,
- allow_subannotations=None, trigger_specs=None, timeout=None,
- infra_step=None, stdout=None, stderr=None, stdin=None,
- ok_ret=None, step_test_data=None, step_nest_level=None):
+ def create(cls, name, base_name=None, cmd=None, cwd=None, env_prefixes=None,
+ env=None, allow_subannotations=None, trigger_specs=None,
+ timeout=None, infra_step=None, stdout=None, stderr=None,
+ stdin=None, ok_ret=None, step_test_data=None,
+ step_nest_level=None):
"""
Initializes a new StepConfig step API dictionary.
@@ -305,6 +316,7 @@ class StepConfig(_StepConfig):
name component of just this step. If None, this will be set to "name".
cmd: command to run. Acceptable types: str, Path, Placeholder, or None.
cwd (str or None): absolute path to working directory for the command
+ env_prefixes (dict): environment prefix variables, described above.
env (dict): overrides for environment variables, described above.
allow_subannotations (bool): if True, lets the step emit its own
annotations. NOTE: Enabling this can cause some buggy behavior. Please
@@ -333,7 +345,8 @@ class StepConfig(_StepConfig):
base_name=(base_name or name),
cmd=cmd,
cwd=cwd,
- env=env,
+ env_prefixes={k: tuple(v) for k, v in (env_prefixes or {}).iteritems()},
+ env=env or {},
allow_subannotations=bool(allow_subannotations),
trigger_specs=[TriggerSpec._create(**trig)
for trig in (trigger_specs or ())],
@@ -349,6 +362,7 @@ class StepConfig(_StepConfig):
def render_to_dict(self):
self = self._replace(
+ env_prefixes={k: list(v) for k, v in self.env_prefixes.iteritems()},
trigger_specs=[trig._render_to_dict()
for trig in (self.trigger_specs or ())],
)
« no previous file with comments | « no previous file | recipe_engine/step_runner.py » ('j') | recipe_modules/context/tests/env.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698