Add API for composing lists in yaml nodes
- Dominant language
- Python
- Stars
- 140
- Forks
- 45
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 6
Description
[See original issue on GitLab](https://gitlab.com/BuildStream/buildstream/-/issues/1062)
In GitLab by [[Gitlab user @tlater]](https://gitlab.com/tlater) on Jul 3, 2019, 11:14
## Background
[//]: # (Provide a background or the root/source that justifies this task or action.)
As part of #1061 we need to perform composition between lists like so:
```
# bar.bst
kind: autotools
dependencies:
(>):
- foo-lib.bst
```
```
# project.conf
elements:
autotools:
dependencies:
- autotools.bst
```
These lists are expected to be composed into this:
```
- autotools.bst
- foo-lib.bst
```
This means we need to do something along the lines of:
```
default_deps = _yaml.node_get(project_conf, list, "dependencies")
deps = _yaml.node_get(element, list, "dependencies")
_yaml.composite(default_deps, deps)
```
But this will not work, because `_yaml.composite()` will only deal with `_yaml.Node`s.
## Task description
We should add some form of an API to allow doing this - I can see either of these things working:
- `_yaml.composite()` learns to deal with plain lists - the problem here is that we'd struggle providing provenance data, and the behavior of `composite(list, list)` isn't obvious (although !1601 will probably make that "safe append", at least for dependencies).
- `_yaml.get_node()` returns proper `_yaml.Node`s when `type=_yaml.Node` for lists - this feels a bit more reasonable, but I'm likely overlooking something :)
## Acceptance Criteria
[//]: # (Acceptance criteria should follow the S.M.A.R.T. principle https://en.wikipedia.org/wiki/SMART_criteria )
We should be able to compose lists without creating naughty synthetic nodes.
----
[//]: # (To review information about possible relevant labels for this issue please view the list of labels: https://gitlab.com/BuildStream/buildstream/labels)
Contributor guide
Research direction
Start by tracing the _yaml.composite(), _yaml.node_get(), and _yaml.get_node() entry points and their list-handling call sites. Determine an API that composes lists without creating synthetic nodes, then verify that the existing dependency examples can produce the combined list while retaining the intended node behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100