pkg/env.Join(): don't modify passed-in maps
Make sure that env.Join() doesn't modify passed-in maps by cloning them and using only the clones. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
parent
15d7179ada
commit
d8bb637050
|
|
@ -8,6 +8,8 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
const whiteSpaces = " \t"
|
||||
|
|
@ -50,8 +52,9 @@ func Map(slice []string) map[string]string {
|
|||
// Join joins the two environment maps with override overriding base.
|
||||
func Join(base map[string]string, override map[string]string) map[string]string {
|
||||
if len(base) == 0 {
|
||||
return override
|
||||
return maps.Clone(override)
|
||||
}
|
||||
base = maps.Clone(base)
|
||||
for k, v := range override {
|
||||
base[k] = v
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue