environment: Support additional CIPD files
Bug: b/292280529
Change-Id: I23ddf31171b832e3d4bbad8cb32ab19630a11fd1
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/158113
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
diff --git a/recipe_modules/environment/api.py b/recipe_modules/environment/api.py
index 2153f1e..3d3f086 100644
--- a/recipe_modules/environment/api.py
+++ b/recipe_modules/environment/api.py
@@ -165,6 +165,9 @@
if not use_constraint_file:
cmd.append('--unpin-pip-packages')
+ for f in options.additional_cipd_files:
+ cmd.extend(('--additional-cipd-file', f))
+
cmd.extend(('--config-file', path(options.config_file)))
top_presentation.logs['config.json'] = pprint.pformat(
diff --git a/recipe_modules/environment/options.proto b/recipe_modules/environment/options.proto
index 17a6f95..418cd5a 100644
--- a/recipe_modules/environment/options.proto
+++ b/recipe_modules/environment/options.proto
@@ -30,4 +30,8 @@
// Additional environment variables to set.
map<string, string> additional_variables = 5;
+
+ // Additional CIPD files to use (on top of those referenced by the
+ // config_file).
+ repeated string additional_cipd_files = 6;
}
diff --git a/recipe_modules/environment/test_api.py b/recipe_modules/environment/test_api.py
index 6d474eb..8dd07ae 100644
--- a/recipe_modules/environment/test_api.py
+++ b/recipe_modules/environment/test_api.py
@@ -31,6 +31,7 @@
relative_pigweed_root='pigweed',
skip_submodule_check=False,
additional_variables=None,
+ additional_cipd_files=None,
):
opts = env_options.Options()
opts.config_file = config_file
@@ -39,6 +40,7 @@
opts.skip_submodule_check = skip_submodule_check
for key, value in (additional_variables or {}).items():
opts.additional_variables[key] = str(value)
+ opts.additional_cipd_files.extend(additional_cipd_files or ())
return self.m.properties(**{name: opts})
diff --git a/recipe_modules/environment/tests/full.expected/doctor-fail.json b/recipe_modules/environment/tests/full.expected/doctor-fail.json
index e1328d7..cd69b3f 100644
--- a/recipe_modules/environment/tests/full.expected/doctor-fail.json
+++ b/recipe_modules/environment/tests/full.expected/doctor-fail.json
@@ -103,6 +103,8 @@
"--strict",
"--skip-submodule-check",
"--unpin-pip-packages",
+ "--additional-cipd-file",
+ "override.json",
"--config-file",
"[START_DIR]/config_file.json"
],
diff --git a/recipe_modules/environment/tests/full.py b/recipe_modules/environment/tests/full.py
index 15fc329..75e869b 100644
--- a/recipe_modules/environment/tests/full.py
+++ b/recipe_modules/environment/tests/full.py
@@ -63,7 +63,9 @@
yield (
api.test('doctor-fail')
- + api.environment.properties(skip_submodule_check=True)
+ + api.environment.properties(
+ skip_submodule_check=True, additional_cipd_files=('override.json',),
+ )
+ api.platform.name('linux')
+ api.step_data('environment.doctor', retcode=1)
)