Skip to content

Commit

Permalink
java: use Layer.FS method
Browse files Browse the repository at this point in the history
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Oct 24, 2023
1 parent 162c725 commit 477e090
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
11 changes: 2 additions & 9 deletions java/packagescanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/quay/claircore"
"github.com/quay/claircore/indexer"
"github.com/quay/claircore/java/jar"
"github.com/quay/claircore/pkg/tarfs"
)

var (
Expand Down Expand Up @@ -116,15 +115,9 @@ func (s *Scanner) Scan(ctx context.Context, layer *claircore.Layer) ([]*claircor
if err := ctx.Err(); err != nil {
return nil, err
}

r, err := layer.Reader()
sys, err := layer.FS()
if err != nil {
return nil, err
}
defer r.Close()
sys, err := tarfs.New(r)
if err != nil {
return nil, err
return nil, fmt.Errorf("java: unable to open layer: %w", err)
}

ars, err := archives(ctx, sys)
Expand Down
19 changes: 3 additions & 16 deletions java/reposcanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ package java

import (
"context"
"errors"
"fmt"
"io"
"runtime/trace"

"github.com/quay/zlog"

"github.com/quay/claircore"
"github.com/quay/claircore/indexer"
"github.com/quay/claircore/pkg/tarfs"
)

var (
Expand Down Expand Up @@ -53,21 +50,11 @@ func (rs *RepoScanner) Scan(ctx context.Context, layer *claircore.Layer) ([]*cla
if err := ctx.Err(); err != nil {
return nil, err
}

r, err := layer.Reader()
sys, err := layer.FS()
if err != nil {
return nil, err
}
defer r.Close()
ra, ok := r.(io.ReaderAt)
if !ok {
err := errors.New("unable to coerce to io.ReaderAt")
return nil, fmt.Errorf("opening layer failed: %w", err)
}
sys, err := tarfs.New(ra)
if err != nil {
return nil, err
return nil, fmt.Errorf("java: unable to open layer: %w", err)
}

ars, err := archives(ctx, sys)
if err != nil {
return nil, err
Expand Down

0 comments on commit 477e090

Please sign in to comment.