Skip to content

Commit

Permalink
Merge pull request #3308 from tonistiigi/ci-fmt-err
Browse files Browse the repository at this point in the history
ci: unbreak linter
  • Loading branch information
AkihiroSuda committed Nov 24, 2022
2 parents 7e14bbd + 3a5d708 commit e8dac6c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 36 deletions.
3 changes: 1 addition & 2 deletions cmd/buildctl/debug/logs.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package debug

import (
"fmt"
"io"
"os"

Expand Down Expand Up @@ -30,7 +29,7 @@ var LogsCommand = cli.Command{
func logs(clicontext *cli.Context) error {
args := clicontext.Args()
if len(args) == 0 {
return fmt.Errorf("build ref must be specified")
return errors.Errorf("build ref must be specified")
}
ref := args[0]

Expand Down
66 changes: 32 additions & 34 deletions exporter/containerimage/attestations.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,56 +41,54 @@ func supplementSBOM(ctx context.Context, s session.Group, target cache.Immutable
}

doc, err := decodeSPDX(content)
if err != nil {
return att, err
}

layers, err := newFileLayerFinder(target, targetRemote)
if err != nil {
return att, err
}
modifyFile := func(f *spdx.File2_2) error {
if f.FileComment != "" {
// Skip over files that already have a comment - since the data is
// unstructured, we can't correctly overwrite this field without
// possibly breaking some scanner functionality.
return nil
if err == nil {
layers, err := newFileLayerFinder(target, targetRemote)
if err != nil {
return att, err
}
modifyFile := func(f *spdx.File2_2) error {
if f.FileComment != "" {
// Skip over files that already have a comment - since the data is
// unstructured, we can't correctly overwrite this field without
// possibly breaking some scanner functionality.
return nil
}

_, desc, err := layers.find(ctx, s, f.FileName)
if err != nil {
if !errors.Is(err, fs.ErrNotExist) {
return err
_, desc, err := layers.find(ctx, s, f.FileName)
if err != nil {
if !errors.Is(err, fs.ErrNotExist) {
return err
}
return nil
}
f.FileComment = fmt.Sprintf("layerID: %s", desc.Digest.String())
return nil
}
f.FileComment = fmt.Sprintf("layerID: %s", desc.Digest.String())
return nil
}
for _, f := range doc.UnpackagedFiles {
if err := modifyFile(f); err != nil {
return att, err
}
}
for _, p := range doc.Packages {
for _, f := range p.Files {
for _, f := range doc.UnpackagedFiles {
if err := modifyFile(f); err != nil {
return att, err
}
}
}
for _, p := range doc.Packages {
for _, f := range p.Files {
if err := modifyFile(f); err != nil {
return att, err
}
}
}

doc.CreationInfo.CreatorTools = append(doc.CreationInfo.CreatorTools, "buildkit-"+version.Version)
doc.CreationInfo.CreatorTools = append(doc.CreationInfo.CreatorTools, "buildkit-"+version.Version)

dt, err := encodeSPDX(doc)
if err != nil {
return att, err
content, err = encodeSPDX(doc)
if err != nil {
return att, err
}
}

return result.Attestation{
Kind: att.Kind,
Path: att.Path,
ContentFunc: func() ([]byte, error) { return dt, nil },
ContentFunc: func() ([]byte, error) { return content, nil },
InToto: att.InToto,
}, nil
}
Expand Down

0 comments on commit e8dac6c

Please sign in to comment.