William Murphy c6ce1de928
make AllLocations accept a context (#2518)
The previous implementation would leak a goroutine if the caller of
AllLocations stopped iterating early. Now, accept a context so that the
caller can cancel the AllLocations iterator rather than leak the
goroutine.

Signed-off-by: Will Murphy <will.murphy@anchore.com>
2024-01-22 11:05:59 -05:00

49 lines
940 B
Go

package fileresolver
import (
"context"
"io"
"github.com/anchore/syft/syft/file"
)
var _ file.WritableResolver = (*Empty)(nil)
type Empty struct{}
func (e Empty) FileContentsByLocation(_ file.Location) (io.ReadCloser, error) {
return nil, nil
}
func (e Empty) HasPath(_ string) bool {
return false
}
func (e Empty) FilesByPath(_ ...string) ([]file.Location, error) {
return nil, nil
}
func (e Empty) FilesByGlob(_ ...string) ([]file.Location, error) {
return nil, nil
}
func (e Empty) FilesByMIMEType(_ ...string) ([]file.Location, error) {
return nil, nil
}
func (e Empty) RelativeFileByPath(_ file.Location, _ string) *file.Location {
return nil
}
func (e Empty) AllLocations(_ context.Context) <-chan file.Location {
return nil
}
func (e Empty) FileMetadataByLocation(_ file.Location) (file.Metadata, error) {
return file.Metadata{}, nil
}
func (e Empty) Write(_ file.Location, _ io.Reader) error {
return nil
}