github.com/anchore/syft@v1.38.2/syft/source/source.go (about) 1 /* 2 Package source provides an abstraction to allow a user to loosely define a data source to catalog and expose a common interface that 3 catalogers and use explore and analyze data from the data source. All valid (cataloggable) data sources are defined 4 within this package. 5 */ 6 package source 7 8 import ( 9 "errors" 10 "io" 11 12 "github.com/anchore/syft/syft/artifact" 13 "github.com/anchore/syft/syft/file" 14 ) 15 16 type Source interface { 17 artifact.Identifiable 18 FileResolver(Scope) (file.Resolver, error) 19 Describe() Description 20 io.Closer 21 } 22 23 type emptySource struct { 24 description Description 25 } 26 27 func FromDescription(d Description) Source { 28 return &emptySource{ 29 description: d, 30 } 31 } 32 33 func (e emptySource) ID() artifact.ID { 34 return artifact.ID(e.description.ID) 35 } 36 37 func (e emptySource) FileResolver(_ Scope) (file.Resolver, error) { 38 return nil, errors.New("no file resolver available for description-only source") 39 } 40 41 func (e emptySource) Describe() Description { 42 return e.description 43 } 44 45 func (e emptySource) Close() error { 46 return nil // no-op 47 }