Skip to content

Commit 7446e48

Browse files
committed
Add substitution for remoteUser
1 parent a74814e commit 7446e48

File tree

7 files changed

+50
-1
lines changed

7 files changed

+50
-1
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"args": [
1515
"up",
1616
"--workspace-folder",
17-
"${workspaceFolder}/src/test/configs/example", // Edit this example config to test the CLI against a custom configuration.
17+
"${workspaceFolder}/test", // Edit this example config to test the CLI against a custom configuration.
1818
"--log-level",
1919
"debug",
2020
],

src/spec-common/variableSubstitution.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface SubstitutionContext {
1515
localWorkspaceFolder?: string;
1616
containerWorkspaceFolder?: string;
1717
env: NodeJS.ProcessEnv;
18+
remoteUser?: string;
1819
}
1920

2021
export function substitute<T extends object>(context: SubstitutionContext, value: T): T {
@@ -109,6 +110,9 @@ function replaceWithContext(isWindows: boolean, context: SubstitutionContext, ma
109110
case 'containerWorkspaceFolderBasename':
110111
return context.containerWorkspaceFolder !== undefined ? path.posix.basename(context.containerWorkspaceFolder) : match;
111112

113+
case 'remoteUser':
114+
return context.remoteUser !== undefined ? context.remoteUser : match;
115+
112116
default:
113117
return match;
114118
}

src/spec-node/configContainer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export async function readDevContainerConfigFile(cliHost: CLIHost, workspace: Wo
9797
containerWorkspaceFolder: workspaceConfig.workspaceFolder,
9898
configFile,
9999
env: cliHost.env,
100+
remoteUser: updated.remoteUser
100101
}, value);
101102
const config: DevContainerConfig = substitute0(updated);
102103
if (typeof config.workspaceFolder === 'string') {

test/.devcontainer/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# [Source] https://github.com/microsoft/vscode-dev-containers/blob/7a4ef23f4034e2f7ded0d2a306561f36677ced9d/containers/python-3/.devcontainer/Dockerfile
2+
3+
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon):
4+
# 3, 3.10, 3.9, 3.8, 3.7, 3.6,
5+
# 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye,
6+
# 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
7+
ARG VARIANT=3.11-bullseye
8+
# dockerfile_lint - ignore
9+
FROM --platform=amd64 mcr.microsoft.com/vscode/devcontainers/python:${VARIANT} as dev
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "Demo container",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": "..",
6+
"args": {
7+
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
8+
// Append -bullseye or -buster to pin to an OS version.
9+
// Use -bullseye variants on local on arm64/Apple Silicon.
10+
"VARIANT": "3.11-bullseye",
11+
// Options
12+
"NODE_VERSION": "lts/*"
13+
}
14+
},
15+
"features": {
16+
"./test-feature": {}
17+
},
18+
"remoteUser": "vscode"
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json",
3+
"id": "test-feature",
4+
"name": "test-feature",
5+
"description": "Testing a feature",
6+
"mounts": [
7+
{
8+
"source": "test-${devcontainerId}",
9+
"target": "/home/${remoteUser}",
10+
"type": "volume"
11+
}
12+
]
13+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
echo "I am the install script"

0 commit comments

Comments
 (0)