Repository navigation
Closed
Labels
Milestone
Description
Version 0.74.0
Updated values, such as remoteEnv in devcontainer.json after the container is created are not respected since the values from the container metadata are taking precedence.
This breaks flows where this values are updated, like secrets, to keep environments working.
The issue appears to be coming from here:
cli/src/spec-node/imageMetadata.ts
Lines 119 to 149 in dadf77b
| const copy = { ...config }; | |
| replaceProperties.forEach(property => delete (copy as any)[property]); | |
| const merged: MergedDevContainerConfig = { | |
| ...copy, | |
| init: imageMetadata.some(entry => entry.init), | |
| privileged: imageMetadata.some(entry => entry.privileged), | |
| capAdd: unionOrUndefined(imageMetadata.map(entry => entry.capAdd)), | |
| securityOpt: unionOrUndefined(imageMetadata.map(entry => entry.securityOpt)), | |
| entrypoints: collectOrUndefined(imageMetadata, 'entrypoint'), | |
| mounts: mergeMounts(imageMetadata), | |
| customizations: Object.keys(customizations).length ? customizations : undefined, | |
| onCreateCommands: collectOrUndefined(imageMetadata, 'onCreateCommand'), | |
| updateContentCommands: collectOrUndefined(imageMetadata, 'updateContentCommand'), | |
| postCreateCommands: collectOrUndefined(imageMetadata, 'postCreateCommand'), | |
| postStartCommands: collectOrUndefined(imageMetadata, 'postStartCommand'), | |
| postAttachCommands: collectOrUndefined(imageMetadata, 'postAttachCommand'), | |
| waitFor: reversed.find(entry => entry.waitFor)?.waitFor, | |
| remoteUser: reversed.find(entry => entry.remoteUser)?.remoteUser, | |
| containerUser: reversed.find(entry => entry.containerUser)?.containerUser, | |
| userEnvProbe: reversed.find(entry => entry.userEnvProbe)?.userEnvProbe, | |
| remoteEnv: Object.assign({}, ...imageMetadata.map(entry => entry.remoteEnv)), | |
| containerEnv: Object.assign({}, ...imageMetadata.map(entry => entry.containerEnv)), | |
| overrideCommand: reversed.find(entry => typeof entry.overrideCommand === 'boolean')?.overrideCommand, | |
| portsAttributes: Object.assign({}, ...imageMetadata.map(entry => entry.portsAttributes)), | |
| otherPortsAttributes: reversed.find(entry => entry.otherPortsAttributes)?.otherPortsAttributes, | |
| forwardPorts: mergeForwardPorts(imageMetadata), | |
| shutdownAction: reversed.find(entry => entry.shutdownAction)?.shutdownAction, | |
| updateRemoteUserUID: reversed.find(entry => typeof entry.updateRemoteUserUID === 'boolean')?.updateRemoteUserUID, | |
| hostRequirements: mergeHostRequirements(imageMetadata), | |
| }; | |
| return merged; |
Activity
Apply current configuration (#252)
chrmarti commentedon Oct 31, 2022
The difficulty here is that
imageMetadatahas the properties from the initial devcontainer.json as its last entry if our CLI created the container as a dev container (e.g., a non-dev container in Compose could still have metadata entries, other tools might do something different).To make sure we don't replace the wrong metadata entry, I suggest we update only the properties that are straight-forward to merge:
remoteEnv,remoteUseranduserEnvProbe.Alternatively we could surface the option
--remote-envto allow for adding / overwriting environment variables.Apply current configuration (#252) (#254)
Apply current configuration (#252) (#254)
Apply current configuration (#252) (#254)
chrmarti commentedon Oct 31, 2022
Fixed in 0.262.1-pre-release. To verify in the Dev Containers extension:
"remoteEnv".