Skip to content

Commit

Permalink
bake: add attest field
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Chadwell <me@jedevc.com>
  • Loading branch information
jedevc committed Nov 28, 2022
1 parent af6785b commit 8570f21
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bake/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ type Target struct {
// Inherits is the only field that cannot be overridden with --set
Inherits []string `json:"inherits,omitempty" hcl:"inherits,optional"`

Attest []string `json:"attest,omitempty" hcl:"attest,optional"`
Context *string `json:"context,omitempty" hcl:"context,optional"`
Contexts map[string]string `json:"contexts,omitempty" hcl:"contexts,optional"`
Dockerfile *string `json:"dockerfile,omitempty" hcl:"dockerfile,optional"`
Expand All @@ -576,6 +577,7 @@ type Target struct {
}

func (t *Target) normalize() {
t.Attest = removeDupes(t.Attest)
t.Tags = removeDupes(t.Tags)
t.Secrets = removeDupes(t.Secrets)
t.SSH = removeDupes(t.SSH)
Expand Down Expand Up @@ -629,6 +631,9 @@ func (t *Target) Merge(t2 *Target) {
if t2.Target != nil {
t.Target = t2.Target
}
if t2.Attest != nil { // merge
t.Attest = append(t.Attest, t2.Attest...)
}
if t2.Secrets != nil { // merge
t.Secrets = append(t.Secrets, t2.Secrets...)
}
Expand Down Expand Up @@ -711,6 +716,8 @@ func (t *Target) AddOverrides(overrides map[string]Override) error {
t.Platforms = o.ArrValue
case "output":
t.Outputs = o.ArrValue
case "attest":
t.Attest = o.ArrValue
case "no-cache":
noCache, err := strconv.ParseBool(value)
if err != nil {
Expand Down Expand Up @@ -964,6 +971,12 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
}
bo.Exports = outputs

attests, err := buildflags.ParseAttests(t.Attest)
if err != nil {
return nil, err
}
bo.Attests = attests

return bo, nil
}

Expand Down

0 comments on commit 8570f21

Please sign in to comment.