Skip to content

Commit 60439ae

Browse files
authored
Merge pull request #3542 from 1032120121/upstream_master
bugfix: override image.Env with process.Env, rather than be contrary
2 parents e07359b + 1c30d4d commit 60439ae

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

oci/spec_opts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ func WithImageConfigArgs(image Image, args []string) SpecOpts {
326326

327327
setProcess(s)
328328
if s.Linux != nil {
329-
s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, config.Env)
329+
s.Process.Env = replaceOrAppendEnvValues(config.Env, s.Process.Env)
330330
cmd := config.Cmd
331331
if len(args) > 0 {
332332
cmd = args
@@ -348,7 +348,7 @@ func WithImageConfigArgs(image Image, args []string) SpecOpts {
348348
// even if there is no specified user in the image config
349349
return WithAdditionalGIDs("root")(ctx, client, c, s)
350350
} else if s.Windows != nil {
351-
s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, config.Env)
351+
s.Process.Env = replaceOrAppendEnvValues(config.Env, s.Process.Env)
352352
cmd := config.Cmd
353353
if len(args) > 0 {
354354
cmd = args

oci/spec_opts_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ func TestWithImageConfigArgs(t *testing.T) {
406406
WithImageConfigArgs(img, []string{"--boo", "bar"}),
407407
}
408408

409-
expectedEnv := []string{"x=foo", "y=baz", "z=bar"}
409+
expectedEnv := []string{"z=bar", "y=boo", "x=foo"}
410410
expectedArgs := []string{"create", "--namespace=test", "--boo", "bar"}
411411

412412
for _, opt := range opts {

0 commit comments

Comments
 (0)