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:
+10
-1
@@ -527,7 +527,7 @@ func toSolveOpt(ctx context.Context, np *noderesolver.ResolvedNode, multiDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range node.ProxyConfig {
|
for k, v := range node.ProxyConfig {
|
||||||
if _, ok := opt.BuildArgs[k]; !ok {
|
if !proxyArgKeyExists(opt.BuildArgs, k) {
|
||||||
so.FrontendAttrs["build-arg:"+k] = v
|
so.FrontendAttrs["build-arg:"+k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -586,6 +586,15 @@ func toSolveOpt(ctx context.Context, np *noderesolver.ResolvedNode, multiDriver
|
|||||||
return &so, releaseF, nil
|
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) {
|
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 opt.Inputs.policy == nil {
|
||||||
if len(opt.Policy) > 0 {
|
if len(opt.Policy) > 0 {
|
||||||
|
|||||||
@@ -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))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user