@@ -698,30 +698,30 @@ type Target struct {
698
698
// Inherits is the only field that cannot be overridden with --set
699
699
Inherits []string `json:"inherits,omitempty" hcl:"inherits,optional" cty:"inherits"`
700
700
701
- Annotations []string `json:"annotations,omitempty" hcl:"annotations,optional" cty:"annotations"`
702
- Attest []string `json:"attest,omitempty" hcl:"attest,optional" cty:"attest"`
703
- Context * string `json:"context,omitempty" hcl:"context,optional" cty:"context"`
704
- Contexts map [string ]string `json:"contexts,omitempty" hcl:"contexts,optional" cty:"contexts"`
705
- Dockerfile * string `json:"dockerfile,omitempty" hcl:"dockerfile,optional" cty:"dockerfile"`
706
- DockerfileInline * string `json:"dockerfile-inline,omitempty" hcl:"dockerfile-inline,optional" cty:"dockerfile-inline"`
707
- Args map [string ]* string `json:"args,omitempty" hcl:"args,optional" cty:"args"`
708
- Labels map [string ]* string `json:"labels,omitempty" hcl:"labels,optional" cty:"labels"`
709
- Tags []string `json:"tags,omitempty" hcl:"tags,optional" cty:"tags"`
710
- CacheFrom buildflags.CacheOptions `json:"cache-from,omitempty" hcl:"cache-from,optional" cty:"cache-from"`
711
- CacheTo buildflags.CacheOptions `json:"cache-to,omitempty" hcl:"cache-to,optional" cty:"cache-to"`
712
- Target * string `json:"target,omitempty" hcl:"target,optional" cty:"target"`
713
- Secrets [] * buildflags.Secret `json:"secret,omitempty" hcl:"secret,optional" cty:"secret"`
714
- SSH [] * buildflags.SSH `json:"ssh,omitempty" hcl:"ssh,optional" cty:"ssh"`
715
- Platforms []string `json:"platforms,omitempty" hcl:"platforms,optional" cty:"platforms"`
716
- Outputs [] * buildflags.ExportEntry `json:"output,omitempty" hcl:"output,optional" cty:"output"`
717
- Pull * bool `json:"pull,omitempty" hcl:"pull,optional" cty:"pull"`
718
- NoCache * bool `json:"no-cache,omitempty" hcl:"no-cache,optional" cty:"no-cache"`
719
- NetworkMode * string `json:"network,omitempty" hcl:"network,optional" cty:"network"`
720
- NoCacheFilter []string `json:"no-cache-filter,omitempty" hcl:"no-cache-filter,optional" cty:"no-cache-filter"`
721
- ShmSize * string `json:"shm-size,omitempty" hcl:"shm-size,optional"`
722
- Ulimits []string `json:"ulimits,omitempty" hcl:"ulimits,optional"`
723
- Call * string `json:"call,omitempty" hcl:"call,optional" cty:"call"`
724
- Entitlements []string `json:"entitlements,omitempty" hcl:"entitlements,optional" cty:"entitlements"`
701
+ Annotations []string `json:"annotations,omitempty" hcl:"annotations,optional" cty:"annotations"`
702
+ Attest []string `json:"attest,omitempty" hcl:"attest,optional" cty:"attest"`
703
+ Context * string `json:"context,omitempty" hcl:"context,optional" cty:"context"`
704
+ Contexts map [string ]string `json:"contexts,omitempty" hcl:"contexts,optional" cty:"contexts"`
705
+ Dockerfile * string `json:"dockerfile,omitempty" hcl:"dockerfile,optional" cty:"dockerfile"`
706
+ DockerfileInline * string `json:"dockerfile-inline,omitempty" hcl:"dockerfile-inline,optional" cty:"dockerfile-inline"`
707
+ Args map [string ]* string `json:"args,omitempty" hcl:"args,optional" cty:"args"`
708
+ Labels map [string ]* string `json:"labels,omitempty" hcl:"labels,optional" cty:"labels"`
709
+ Tags []string `json:"tags,omitempty" hcl:"tags,optional" cty:"tags"`
710
+ CacheFrom buildflags.CacheOptions `json:"cache-from,omitempty" hcl:"cache-from,optional" cty:"cache-from"`
711
+ CacheTo buildflags.CacheOptions `json:"cache-to,omitempty" hcl:"cache-to,optional" cty:"cache-to"`
712
+ Target * string `json:"target,omitempty" hcl:"target,optional" cty:"target"`
713
+ Secrets buildflags.Secrets `json:"secret,omitempty" hcl:"secret,optional" cty:"secret"`
714
+ SSH buildflags.SSHKeys `json:"ssh,omitempty" hcl:"ssh,optional" cty:"ssh"`
715
+ Platforms []string `json:"platforms,omitempty" hcl:"platforms,optional" cty:"platforms"`
716
+ Outputs buildflags.Exports `json:"output,omitempty" hcl:"output,optional" cty:"output"`
717
+ Pull * bool `json:"pull,omitempty" hcl:"pull,optional" cty:"pull"`
718
+ NoCache * bool `json:"no-cache,omitempty" hcl:"no-cache,optional" cty:"no-cache"`
719
+ NetworkMode * string `json:"network,omitempty" hcl:"network,optional" cty:"network"`
720
+ NoCacheFilter []string `json:"no-cache-filter,omitempty" hcl:"no-cache-filter,optional" cty:"no-cache-filter"`
721
+ ShmSize * string `json:"shm-size,omitempty" hcl:"shm-size,optional"`
722
+ Ulimits []string `json:"ulimits,omitempty" hcl:"ulimits,optional"`
723
+ Call * string `json:"call,omitempty" hcl:"call,optional" cty:"call"`
724
+ Entitlements []string `json:"entitlements,omitempty" hcl:"entitlements,optional" cty:"entitlements"`
725
725
// IMPORTANT: if you add more fields here, do not forget to update newOverrides/AddOverrides and docs/bake-reference.md.
726
726
727
727
// linked is a private field to mark a target used as a linked one
@@ -739,12 +739,12 @@ func (t *Target) normalize() {
739
739
t .Annotations = removeDupesStr (t .Annotations )
740
740
t .Attest = removeAttestDupes (t .Attest )
741
741
t .Tags = removeDupesStr (t .Tags )
742
- t .Secrets = removeDupes ( t .Secrets )
742
+ t .Secrets = t .Secrets . Normalize ( )
743
743
t .SSH = removeDupes (t .SSH )
744
744
t .Platforms = removeDupesStr (t .Platforms )
745
745
t .CacheFrom = t .CacheFrom .Normalize ()
746
746
t .CacheTo = t .CacheTo .Normalize ()
747
- t .Outputs = removeDupes ( t .Outputs )
747
+ t .Outputs = t .Outputs . Normalize ( )
748
748
t .NoCacheFilter = removeDupesStr (t .NoCacheFilter )
749
749
t .Ulimits = removeDupesStr (t .Ulimits )
750
750
@@ -815,10 +815,10 @@ func (t *Target) Merge(t2 *Target) {
815
815
t .Attest = removeAttestDupes (t .Attest )
816
816
}
817
817
if t2 .Secrets != nil { // merge
818
- t .Secrets = append ( t .Secrets , t2 .Secrets ... )
818
+ t .Secrets = t .Secrets . Merge ( t2 .Secrets )
819
819
}
820
820
if t2 .SSH != nil { // merge
821
- t .SSH = append ( t .SSH , t2 .SSH ... )
821
+ t .SSH = t .SSH . Merge ( t2 .SSH )
822
822
}
823
823
if t2 .Platforms != nil { // no merge
824
824
t .Platforms = t2 .Platforms
@@ -1333,13 +1333,8 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
1333
1333
}
1334
1334
bo .Platforms = platforms
1335
1335
1336
- secrets := make ([]* controllerapi.Secret , len (t .Secrets ))
1337
- for i , s := range t .Secrets {
1338
- secrets [i ] = s .ToPB ()
1339
- }
1340
- bo .SecretSpecs = secrets
1341
-
1342
- secretAttachment , err := controllerapi .CreateSecrets (secrets )
1336
+ bo .SecretSpecs = t .Secrets .ToPB ()
1337
+ secretAttachment , err := controllerapi .CreateSecrets (bo .SecretSpecs )
1343
1338
if err != nil {
1344
1339
return nil , err
1345
1340
}
@@ -1379,12 +1374,7 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
1379
1374
bo .CacheTo = controllerapi .CreateCaches (t .CacheTo .ToPB ())
1380
1375
}
1381
1376
1382
- outputs := make ([]* controllerapi.ExportEntry , len (t .Outputs ))
1383
- for i , output := range t .Outputs {
1384
- outputs [i ] = output .ToPB ()
1385
- }
1386
-
1387
- bo .Exports , bo .ExportsLocalPathsTemporary , err = controllerapi .CreateExports (outputs )
1377
+ bo .Exports , bo .ExportsLocalPathsTemporary , err = controllerapi .CreateExports (t .Outputs .ToPB ())
1388
1378
if err != nil {
1389
1379
return nil , err
1390
1380
}
@@ -1611,6 +1601,10 @@ type arrValue[B any] interface {
1611
1601
func parseArrValue [T any , PT arrValue [T ]](s []string ) ([]* T , error ) {
1612
1602
outputs := make ([]* T , 0 , len (s ))
1613
1603
for _ , text := range s {
1604
+ if text == "" {
1605
+ continue
1606
+ }
1607
+
1614
1608
output := new (T )
1615
1609
if err := PT (output ).UnmarshalText ([]byte (text )); err != nil {
1616
1610
return nil , err
0 commit comments