mirror of
https://github.com/moby/buildkit.git
synced 2026-11-06 05:16:45 +00:00
Route proxy-network traffic through HTTP_PROXY and HTTPS_PROXY from the buildkitd environment. Propagate ALL_PROXY to gateway execs and document upstream proxy behavior. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
22 lines
587 B
Go
22 lines
587 B
Go
package executor
|
|
|
|
import "strings"
|
|
|
|
// ReplaceEnv removes entries whose names are present in replacement, then
|
|
// appends replacement in order.
|
|
func ReplaceEnv(env, replacement []string) []string {
|
|
names := make(map[string]struct{}, len(replacement))
|
|
for _, entry := range replacement {
|
|
name, _, _ := strings.Cut(entry, "=")
|
|
names[name] = struct{}{}
|
|
}
|
|
out := make([]string, 0, len(env)+len(replacement))
|
|
for _, entry := range env {
|
|
name, _, _ := strings.Cut(entry, "=")
|
|
if _, ok := names[name]; !ok {
|
|
out = append(out, entry)
|
|
}
|
|
}
|
|
return append(out, replacement...)
|
|
}
|