devcontainers / devcontainers/spec

Support for referencing feature option values in containerEnv

Open
#164 6 comments 7 reactions 0 assignees View on GitHub
proposal
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.