diff --git a/src/spec-common/variableSubstitution.ts b/src/spec-common/variableSubstitution.ts index d973f0cd6..accdff3bb 100644 --- a/src/spec-common/variableSubstitution.ts +++ b/src/spec-common/variableSubstitution.ts @@ -15,6 +15,7 @@ export interface SubstitutionContext { localWorkspaceFolder?: string; containerWorkspaceFolder?: string; env: NodeJS.ProcessEnv; + remoteUser?: string; } export function substitute(context: SubstitutionContext, value: T): T { @@ -109,6 +110,9 @@ function replaceWithContext(isWindows: boolean, context: SubstitutionContext, ma case 'containerWorkspaceFolderBasename': return context.containerWorkspaceFolder !== undefined ? path.posix.basename(context.containerWorkspaceFolder) : match; + case 'remoteUser': + return context.remoteUser !== undefined ? context.remoteUser : match; + default: return match; } diff --git a/src/spec-node/configContainer.ts b/src/spec-node/configContainer.ts index dddd08d58..ecffa5c87 100644 --- a/src/spec-node/configContainer.ts +++ b/src/spec-node/configContainer.ts @@ -97,6 +97,7 @@ export async function readDevContainerConfigFile(cliHost: CLIHost, workspace: Wo containerWorkspaceFolder: workspaceConfig.workspaceFolder, configFile, env: cliHost.env, + remoteUser: updated.remoteUser }, value); const config: DevContainerConfig = substitute0(updated); if (typeof config.workspaceFolder === 'string') { diff --git a/src/test/configs/image-with-local-feature/.devcontainer/devcontainer.json b/src/test/configs/image-with-local-feature/.devcontainer/devcontainer.json new file mode 100644 index 000000000..0749ce284 --- /dev/null +++ b/src/test/configs/image-with-local-feature/.devcontainer/devcontainer.json @@ -0,0 +1,8 @@ +{ + "name": "Demo container", + "image": "mcr.microsoft.com/devcontainers/base:bullseye", + "features": { + "./test-feature": {} + }, + "remoteUser": "vscode" +} \ No newline at end of file diff --git a/src/test/configs/image-with-local-feature/.devcontainer/test-feature/devcontainer-feature.json b/src/test/configs/image-with-local-feature/.devcontainer/test-feature/devcontainer-feature.json new file mode 100644 index 000000000..f2da6e155 --- /dev/null +++ b/src/test/configs/image-with-local-feature/.devcontainer/test-feature/devcontainer-feature.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json", + "id": "test-feature", + "name": "test-feature", + "version": "0.0.1", + "description": "Testing a feature", + "mounts": [ + { + "source": "test-${devcontainerId}", + "target": "/home/${remoteUser}", + "type": "volume" + } + ] +} \ No newline at end of file diff --git a/src/test/configs/image-with-local-feature/.devcontainer/test-feature/install.sh b/src/test/configs/image-with-local-feature/.devcontainer/test-feature/install.sh new file mode 100644 index 000000000..41cde2f90 --- /dev/null +++ b/src/test/configs/image-with-local-feature/.devcontainer/test-feature/install.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "I am the install script and I do nothing." \ No newline at end of file