bugfix: override image.Env with process.Env, rather than be contrary
Signed-off-by: Yangyang <1032120121@163.com>
This commit is contained in:
parent
074b75907b
commit
1c30d4d04c
@ -326,7 +326,7 @@ func WithImageConfigArgs(image Image, args []string) SpecOpts {
|
|||||||
|
|
||||||
setProcess(s)
|
setProcess(s)
|
||||||
if s.Linux != nil {
|
if s.Linux != nil {
|
||||||
s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, config.Env)
|
s.Process.Env = replaceOrAppendEnvValues(config.Env, s.Process.Env)
|
||||||
cmd := config.Cmd
|
cmd := config.Cmd
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
cmd = args
|
cmd = args
|
||||||
@ -348,7 +348,7 @@ func WithImageConfigArgs(image Image, args []string) SpecOpts {
|
|||||||
// even if there is no specified user in the image config
|
// even if there is no specified user in the image config
|
||||||
return WithAdditionalGIDs("root")(ctx, client, c, s)
|
return WithAdditionalGIDs("root")(ctx, client, c, s)
|
||||||
} else if s.Windows != nil {
|
} else if s.Windows != nil {
|
||||||
s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, config.Env)
|
s.Process.Env = replaceOrAppendEnvValues(config.Env, s.Process.Env)
|
||||||
cmd := config.Cmd
|
cmd := config.Cmd
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
cmd = args
|
cmd = args
|
||||||
|
@ -406,7 +406,7 @@ func TestWithImageConfigArgs(t *testing.T) {
|
|||||||
WithImageConfigArgs(img, []string{"--boo", "bar"}),
|
WithImageConfigArgs(img, []string{"--boo", "bar"}),
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedEnv := []string{"x=foo", "y=baz", "z=bar"}
|
expectedEnv := []string{"z=bar", "y=boo", "x=foo"}
|
||||||
expectedArgs := []string{"create", "--namespace=test", "--boo", "bar"}
|
expectedArgs := []string{"create", "--namespace=test", "--boo", "bar"}
|
||||||
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
|
Loading…
Reference in New Issue
Block a user