Merge pull request #2861 from tonistiigi/v0.19-set-empty-eof

[v0.19] bake: remove empty values set by --set
This commit is contained in:
Tõnis Tiigi 2024-12-16 10:16:22 -08:00 committed by GitHub
commit 62d486d5a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 29 additions and 0 deletions

View File

@ -2028,3 +2028,20 @@ target "app" {
_, _, err := ReadTargets(ctx, []File{fp}, []string{"app"}, nil, nil, &EntitlementConf{}) _, _, err := ReadTargets(ctx, []File{fp}, []string{"app"}, nil, nil, &EntitlementConf{})
require.NoError(t, err) require.NoError(t, err)
} }
// https://github.com/docker/buildx/issues/2858
func TestOverrideEmpty(t *testing.T) {
fp := File{
Name: "docker-bake.hcl",
Data: []byte(`
target "app" {
output = ["./bin"]
}
`),
}
ctx := context.TODO()
_, _, err := ReadTargets(ctx, []File{fp}, []string{"app"}, []string{"app.output="}, nil, &EntitlementConf{})
require.NoError(t, err)
}

View File

@ -14,6 +14,9 @@ import (
func ParseCacheEntry(in []string) ([]*controllerapi.CacheOptionsEntry, error) { func ParseCacheEntry(in []string) ([]*controllerapi.CacheOptionsEntry, error) {
outs := make([]*controllerapi.CacheOptionsEntry, 0, len(in)) outs := make([]*controllerapi.CacheOptionsEntry, 0, len(in))
for _, in := range in { for _, in := range in {
if in == "" {
continue
}
fields, err := csvvalue.Fields(in, nil) fields, err := csvvalue.Fields(in, nil)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -19,6 +19,9 @@ func ParseExports(inp []string) ([]*controllerapi.ExportEntry, error) {
return nil, nil return nil, nil
} }
for _, s := range inp { for _, s := range inp {
if s == "" {
continue
}
fields, err := csvvalue.Fields(s, nil) fields, err := csvvalue.Fields(s, nil)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -11,6 +11,9 @@ import (
func ParseSecretSpecs(sl []string) ([]*controllerapi.Secret, error) { func ParseSecretSpecs(sl []string) ([]*controllerapi.Secret, error) {
fs := make([]*controllerapi.Secret, 0, len(sl)) fs := make([]*controllerapi.Secret, 0, len(sl))
for _, v := range sl { for _, v := range sl {
if v == "" {
continue
}
s, err := parseSecret(v) s, err := parseSecret(v)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -14,6 +14,9 @@ func ParseSSHSpecs(sl []string) ([]*controllerapi.SSH, error) {
} }
for _, s := range sl { for _, s := range sl {
if s == "" {
continue
}
parts := strings.SplitN(s, "=", 2) parts := strings.SplitN(s, "=", 2)
out := controllerapi.SSH{ out := controllerapi.SSH{
ID: parts[0], ID: parts[0],