-
Notifications
You must be signed in to change notification settings - Fork 295
Allow using ${remoteUser}
inside of features
#525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c47cb27
6bdccac
cf32d27
1afe943
92ca28c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,7 @@ export async function readDevContainerConfigFile(cliHost: CLIHost, workspace: Wo | |
containerWorkspaceFolder: workspaceConfig.workspaceFolder, | ||
configFile, | ||
env: cliHost.env, | ||
remoteUser: updated.remoteUser | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
{
"name": "Demo container",
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
"features": {
"./test-feature": {}
},
"remoteUser": "${localEnv:DEV_CONTAINER_USER}",
"postCreateCommand": "echo ${remoteUser} > /tmp/container.variable-substitution.testMarker"
} Maybe there needs to be a second pass for substituting Another case to consider is when the What if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There's a lot of tests here that could help assert the behavior when (If you're curious what metadata is attached to an image, this is how I generally take a peek at it on the fly:) $ docker pull mcr.microsoft.com/devcontainers/base:bullseye
bullseye: Pulling from devcontainers/base
Digest: sha256:cd9bbfbe4d380278d08fe22c39c5801667424a059c59368819a89ad22ff6936f
Status: Image is up to date for mcr.microsoft.com/devcontainers/base:bullseye
mcr.microsoft.com/devcontainers/base:bullseye
$ export IMAGE="mcr.microsoft.com/devcontainers/base:bullseye"
$ docker image inspect "$IMAGE" | jq '.[0].Config.Labels."devcontainer.metadata" | fromjson'
[
{
"id": "ghcr.io/devcontainers/features/common-utils:2"
},
{
"id": "ghcr.io/devcontainers/features/git:1"
},
{
"remoteUser": "vscode"
}
]
That's a good point that I did not think of, perhaps it should align with those variable (info here https://containers.dev/implementors/features/#user-env-var) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @chrmarti, hello @joshspicer, I understood the assignment. Configuration options can come from many different sources. Relying on the devcontainer.json to contain them is not the proper way to go. Usually I'm pretty good at reading foreign code and getting the gist of it. At least enough to be able to provide smaller bugfixes and features. This project here... doesn't work very well with my brain. I'm having a hard time following along the different workflows without seeing the red string showing a common structure. Most likely the lack of experience on my side, I'm more ops than dev. I'll give it another shot next weekend, unless one of you already knows where to use the screwdriver. Feel free to do whatever needs to be done, I definitely won't complain. |
||
}, value); | ||
const config: DevContainerConfig = substitute0(updated); | ||
if (typeof config.workspaceFolder === 'string') { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "Demo container", | ||
"image": "mcr.microsoft.com/devcontainers/base:bullseye", | ||
"features": { | ||
"./test-feature": {} | ||
}, | ||
"remoteUser": "vscode", | ||
"postCreateCommand": "echo ${remoteUser} > /tmp/container.variable-substitution.testMarker" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$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}", | ||
joshspicer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"type": "volume" | ||
} | ||
], | ||
"postCreateCommand": "/usr/bin/whoami && echo ${remoteUser} > /tmp/feature.variable-substitution.testMarker" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
echo "I am the install script and I do nothing." |
Uh oh!
There was an error while loading. Please reload this page.