Skip to content

Commit 084a01f

Browse files
committed
Fix OCI env cache keying
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 43ec1dd commit 084a01f

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

internal/ociedit/spec_editor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ type nativeSpecEditor struct {
6767
func createEnvCacheMap(env []string) map[string]int {
6868
envMap := make(map[string]int, len(env))
6969
for i, val := range env {
70+
val, _, _ = strings.Cut(val, "=")
7071
envMap[val] = i
7172
}
7273
return envMap

pkg/cdi/container-edits_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ func TestApplyContainerEdits(t *testing.T) {
415415
},
416416
},
417417
{
418-
name: "non-empty spec, env var with existing key is appended",
418+
name: "non-empty spec, env var with existing key is replaced",
419419
spec: &oci.Spec{
420420
Process: &oci.Process{
421421
Env: []string{
@@ -432,9 +432,8 @@ func TestApplyContainerEdits(t *testing.T) {
432432
result: &oci.Spec{
433433
Process: &oci.Process{
434434
Env: []string{
435-
"FOO=old",
436-
"BAR=old",
437435
"FOO=new",
436+
"BAR=old",
438437
},
439438
},
440439
},

0 commit comments

Comments
 (0)