Skip to content

Commit 4e91831

Browse files
aledbfclaude
andcommitted
fix(cli): write the config's containerEnv into up's Features image
TS getFeaturesBuildOptions adds devcontainer.json's containerEnv to the Features Dockerfile as ENV lines (#{containerEnvMetadata}) for every command; build passed it, up did not, so an image built by up lacked those variables (fixture image-metadata-containerEnv, whose up entry now names only the label difference left). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent dddc636 commit 4e91831

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎internal/cli/differential_runtime_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var differentialRuntimeKnown = map[string]map[string]string{
3535
"dockerfile-with-parallel-commands": "the image label leaves out the configuration's entry",
3636
"dockerfile-without-features": "the image label leaves out the configuration's entry",
3737
"image": "the container label holds the substituted configuration and runArgs; TS writes the raw one, without runArgs",
38-
"image-metadata-containerEnv": "the configuration's containerEnv is not written into the Features image as ENV",
38+
"image-metadata-containerEnv": "the image label leaves out the configuration's entry",
3939
"image-with-features": "the image label leaves out the configuration's entry",
4040
"image-with-git-feature": "the image label leaves out the configuration's entry",
4141
"updateUID": "a container from a Dockerfile gets a container label repeating the image label; TS adds none",

‎internal/cli/up.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,5 +1365,8 @@ func (r *upRunner) featureBuildOptions(cfg *config.DevContainer, loadResult *con
13651365
ConfigPath: cfg.ConfigFilePath,
13661366
LockfileExcludeIDs: opts.lockfileExcludeIDs,
13671367
HostSub: &loadResult.HostSub,
1368+
// TS getFeaturesBuildOptions writes the config's containerEnv into the
1369+
// Features image as ENV lines (#{containerEnvMetadata}).
1370+
ContainerEnv: cfg.ContainerEnv,
13681371
}
13691372
}

‎internal/cli/up_held_test.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,3 +659,13 @@ func TestAddUpConfigurationDropsAConfigFilePathThatResolvesToNothing(t *testing.
659659
t.Errorf("mergedConfiguration.configFilePath = %v, want it left out", v)
660660
}
661661
}
662+
663+
// up's Features build writes the configuration's containerEnv into the image
664+
// as ENV lines, as TS getFeaturesBuildOptions does and build already did.
665+
func TestUpFeatureBuildOptionsCarryTheContainerEnv(t *testing.T) {
666+
cfg := &config.DevContainer{ContainerEnv: map[string]string{"VAR_WITH_SPACES": "value with spaces"}}
667+
got := (&upRunner{opts: &upOpts{}}).featureBuildOptions(cfg, &config.LoadResult{}, "").ContainerEnv
668+
if !reflect.DeepEqual(got, cfg.ContainerEnv) {
669+
t.Errorf("ContainerEnv = %v, want the config's %v", got, cfg.ContainerEnv)
670+
}
671+
}

0 commit comments

Comments
 (0)