Debian Codegraph @

third_party/python/taskcluster_taskgraph/taskgraph/loader/default.py

raw
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
6 import logging
7
8 from .transform import loader as transform_loader
9
10 logger = logging.getLogger(__name__)
11
12
13 DEFAULT_TRANSFORMS = [
14 "taskgraph.transforms.run:transforms",
15 "taskgraph.transforms.task:transforms",
16 ]
17
18
19 def loader(kind, path, config, params, loaded_tasks):
20 """
21 This default loader builds on the `transform` loader by providing sensible
22 default transforms that the majority of simple tasks will need.
23 Specifically, `run` and `task` transforms will be appended to the end of the
24 list of transforms in the kind being loaded.
25 """
26 transform_refs = config.setdefault("transforms", [])
27 for t in DEFAULT_TRANSFORMS:
28 if t in config.get("transforms", ()):
29 raise KeyError(
30 f"Transform {t} is already present in the loader's default transforms; it must not be defined in the kind"
31 )
32 transform_refs.extend(DEFAULT_TRANSFORMS)
33 return transform_loader(kind, path, config, params, loaded_tasks)