devcontainers / devcontainers/spec
Support for referencing feature option values in containerEnv
- Dominant language
- No language data
- Stars
- 5.7k
- Forks
- 496
- PR merge metrics
- No merged PRs in 30d
Description
We have a case where we need to define a Container env variable, that depends on the value of an option.
Although possible to inject the env variable in .profile, .bashrc or similar in `install.sh`, this causes an issue when using the build image in CI/CD, specifically in Azure Pipelines when bash is launched with the `--noprofile --norc` flags.
As an example:
```
{
"id": "some-feature",
"version": "0.0.1",
"options": {
"version": {
"type": "string",
"proposals": [
"latest"
],
"default": "latest",
"description": "Select or enter a version"
}
},
"containerEnv": {
"FEATURE_HOME": "/opt/feature//bin",
}
}
```
Maybe something similar to the pre-defined variables `${localEnv:VARIABLE_NAME}` would work, like `${option:optionName}`?
In context:
```
{
"id": "some-feature",
"version": "0.0.1",
"options": {
"version": {
"type": "string",
"proposals": [
"latest"
],
"default": "latest",
"description": "Select or enter a version"
}
},
"containerEnv": {
"FEATURE_HOME": "/opt/feature/${option:version}/bin",
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.