release_snap_repackage.py (1209B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 from taskgraph.transforms.base import TransformSequence 6 from taskgraph.util.schema import resolve_keyed_by 7 8 from gecko_taskgraph.util.attributes import release_level 9 from gecko_taskgraph.util.scriptworker import get_release_config 10 11 transforms = TransformSequence() 12 13 14 @transforms.add 15 def format(config, tasks): 16 """Apply format substitution to worker.env and worker.command.""" 17 18 format_params = { 19 "release_config": get_release_config(config), 20 "config_params": config.params, 21 } 22 23 for task in tasks: 24 format_params["task"] = task 25 26 command = task.get("worker", {}).get("command", []) 27 task["worker"]["command"] = [x.format(**format_params) for x in command] 28 29 env = task.get("worker", {}).get("env", {}) 30 for k in env.keys(): 31 resolve_keyed_by( 32 env, k, "snap envs", **{"release-level": release_level(config.params)} 33 ) 34 task["worker"]["env"][k] = env[k].format(**format_params) 35 36 yield task