build: make proxy build-arg override check case-insensitive

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2026-03-05 16:16:54 +01:00
parent d315c086c3
commit 189633f43c
2 changed files with 50 additions and 1 deletions
+10 -1
View File
@@ -527,7 +527,7 @@ func toSolveOpt(ctx context.Context, np *noderesolver.ResolvedNode, multiDriver
}
for k, v := range node.ProxyConfig {
if _, ok := opt.BuildArgs[k]; !ok {
if !proxyArgKeyExists(opt.BuildArgs, k) {
so.FrontendAttrs["build-arg:"+k] = v
}
}
@@ -586,6 +586,15 @@ func toSolveOpt(ctx context.Context, np *noderesolver.ResolvedNode, multiDriver
return &so, releaseF, nil
}
func proxyArgKeyExists(buildArgs map[string]string, key string) bool {
for k := range buildArgs {
if strings.EqualFold(k, key) {
return true
}
}
return false
}
func configureSourcePolicy(ctx context.Context, np *noderesolver.ResolvedNode, opt *Options, cfg *confutil.Config, bopts gateway.BuildOpts, so *client.SolveOpt, pw progress.Writer) (defers []func(error), err error) {
if opt.Inputs.policy == nil {
if len(opt.Policy) > 0 {
+40
View File
@@ -156,3 +156,43 @@ func TestCreateExports_RegistryUnpack(t *testing.T) {
})
}
}
func TestProxyArgKeyExists(t *testing.T) {
tests := []struct {
name string
proxyArgs map[string]string
key string
want bool
}{
{
name: "exact match",
proxyArgs: map[string]string{"NO_PROXY": "cli"},
key: "NO_PROXY",
want: true,
},
{
name: "case insensitive match",
proxyArgs: map[string]string{"no_proxy": "cli"},
key: "NO_PROXY",
want: true,
},
{
name: "no match",
proxyArgs: map[string]string{"HTTP_PROXY": "cli"},
key: "NO_PROXY",
want: false,
},
{
name: "nil map",
proxyArgs: nil,
key: "NO_PROXY",
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.want, proxyArgKeyExists(tt.proxyArgs, tt.key))
})
}
}