spec icon indicating copy to clipboard operation
spec copied to clipboard

Duplication while merging lifecycle commands?

Open avidal opened this issue 2 years ago • 1 comments

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:

// 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:

{ "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 to suggest avoiding using the same devcontainer.json as the one used to make the prebuild.

avidal avatar Jun 28 '23 16:06 avidal

Thanks for opening @avidal!

@joshspicer it'd be great to get your insights on this one.

bamurtaugh avatar Jul 27 '23 22:07 bamurtaugh