devcontainers / devcontainers/spec
Duplication while merging lifecycle commands?
- Dominant language
- No language data
- Stars
- 5.7k
- Forks
- 496
- PR merge metrics
- No merged PRs in 30d
Description
While I'm going deep on config merge logic, I realized that there may be an opportunity to clarify what should happen in a merge where lifecycle commands are stored in image metadata that are duplicates of lifecycle commands defined in the devcontainer.json or devcontainer-feature.json.
Consider the following:
```js
// devcontainer.json
{ "onCreateCommand": {"db": "script/migrate"}}
// devcontainer-feature.json
{ "onCreateCommand": ["/usr/share/devcontainer/features/statics/build-static"] }
```
If you prebuild the container, you'll end up with the following stored in the `devcontainer.metadata` image label:
```json
{ "onCreateCommand": [
{"db": "script/migrate"},
["/usr/share/devcontainer/features/statics/build-static"]
]}
```
Later, you want to create a devcontainer using this prebuild (and using the same devcontainer.json). According to the spec, I believe you'd end up duplicating `onCreateCommand` and ending up with four entries.
EDIT: Maybe it's sufficient to expand on the [metadata in image labels section](https://containers.dev/implementors/reference/#labels) to suggest avoiding using the same devcontainer.json as the one used to make the prebuild.
Contributor guide
Assessment
This issue has not been assessed yet.