Skip to content

Commit

Permalink
pkg/build/sbom: use new-style errors rather than errors pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
kaniini committed Mar 5, 2022
1 parent cbe0ada commit 1bfc087
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/build/image_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (bc *Context) BuildImage() error {
if bc.SBOMPath != "" {
err = bc.GenerateSBOM()
if err != nil {
return errors.Wrap(err, "failed to generate SBOM")
return fmt.Errorf("failed to generate SBOM: %w", err)
}
}

Expand Down
9 changes: 4 additions & 5 deletions pkg/build/sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"strings"

osr "github.com/dominodatalab/os-release"
"github.com/pkg/errors"
"gitlab.alpinelinux.org/alpine/go/pkg/repository"
)

Expand Down Expand Up @@ -75,13 +74,13 @@ func (bc *Context) GenerateSBOM() error {

installedDB, err := os.Open(filepath.Join(bc.WorkDir, "lib", "apk", "db", "installed"))
if err != nil {
return errors.Wrap(err, "unable to open APK installed db")
return fmt.Errorf("unable to open APK installed db: %w", err)
}

// repository.ParsePackageIndex closes the file itself
packages, err := repository.ParsePackageIndex(installedDB)
if err != nil {
return errors.Wrap(err, "unable to parse APK installed db")
return fmt.Errorf("unable to parse APK installed db: %w", err)
}

// TODO(kaniini): figure out something better to do than this
Expand Down Expand Up @@ -164,7 +163,7 @@ func (bc *Context) GenerateSBOM() error {

out, err := os.Create(bc.SBOMPath)
if err != nil {
return errors.Wrapf(err, "unable to open SBOM path %s for writing", bc.SBOMPath)
return fmt.Errorf("unable to open SBOM path %s for writing: %w", bc.SBOMPath, err)
}
defer out.Close()

Expand All @@ -173,7 +172,7 @@ func (bc *Context) GenerateSBOM() error {

err = enc.Encode(bom)
if err != nil {
return errors.Wrap(err, "unable to encode BOM")
return fmt.Errorf("unable to encode BOM: %w", err)
}

return nil
Expand Down

0 comments on commit 1bfc087

Please sign in to comment.