Documentation
¶
Index ¶
- Constants
- type Converter
- type ErrUnhandledPurl
- type ErrUnknownDetector
- type GenerateFunc
- type ParseFunc
- type Registry
- func (r *Registry) Generate(ctx context.Context, ir *claircore.IndexRecord) (packageurl.PackageURL, error)
- func (r *Registry) Parse(ctx context.Context, purl packageurl.PackageURL) ([]*claircore.IndexRecord, error)
- func (r *Registry) RegisterDetector(s indexer.PackageScanner, GenFn GenerateFunc)
- func (r *Registry) RegisterPurlType(purlType string, purlNamespace string, ParseFn ParseFunc, ...)
- type TransformerFunc
Constants ¶
const ( // NoneNamespace is a placeholder namespace for PURLs that are not associated with // a specific namespace (optional according to the PURL spec), this is a canonical // value that can be used with [Registry.RegisterPurlType] to register a PURL type // without a namespace. NoneNamespace = "none" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Converter ¶
type Converter interface {
Generate(ctx context.Context, ir *claircore.IndexRecord) (packageurl.PackageURL, error)
Parse(ctx context.Context, purl packageurl.PackageURL) ([]*claircore.IndexRecord, error)
}
Converter is an interface that provides methods for generating and parsing PURLs.
type ErrUnhandledPurl ¶
ErrUnhandledPurl is returned when a PURL parser is not registered for a PURL type.
func (ErrUnhandledPurl) Error ¶
func (e ErrUnhandledPurl) Error() string
Error returns the error message.
type ErrUnknownDetector ¶
type ErrUnknownDetector struct{ DetectorName string }
ErrUnknownDetector is returned when a PURL generator is not registered for a detector.
func (ErrUnknownDetector) Error ¶
func (e ErrUnknownDetector) Error() string
Error returns the error message.
type GenerateFunc ¶
type GenerateFunc func(ctx context.Context, ir *claircore.IndexRecord) (packageurl.PackageURL, error)
GenerateFunc produces a PackageURL for a given IndexRecord.
type ParseFunc ¶
type ParseFunc func(ctx context.Context, purl packageurl.PackageURL) ([]*claircore.IndexRecord, error)
ParseFunc produces IndexRecords for a given PackageURL.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a thread-safe registry of PURL generators and parsers.
func (*Registry) Generate ¶
func (r *Registry) Generate(ctx context.Context, ir *claircore.IndexRecord) (packageurl.PackageURL, error)
Generate finds a registered generator by the package's claircore.Detector.Name and returns the generated PackageURL.
func (*Registry) Parse ¶
func (r *Registry) Parse(ctx context.Context, purl packageurl.PackageURL) ([]*claircore.IndexRecord, error)
Parse finds a registered parser and transform functions by the PURL's namespace and type. It then runs all transform functions and returns the parsed IndexRecords.
func (*Registry) RegisterDetector ¶
func (r *Registry) RegisterDetector(s indexer.PackageScanner, GenFn GenerateFunc)
RegisterDetector registers using an indexer.PackageScanner (for its Name).
func (*Registry) RegisterPurlType ¶
func (r *Registry) RegisterPurlType(purlType string, purlNamespace string, ParseFn ParseFunc, transformFuncs ...TransformerFunc)
RegisterPurlType registers using a purl type. Transform functions are applied in registration order to the PackageURL before it is parsed.
type TransformerFunc ¶
type TransformerFunc func(ctx context.Context, purl *packageurl.PackageURL) error
TransformerFunc transforms a PackageURL before it is parsed. Transform functions should take care to not overwrite existing qualifiers. If the Namespace or Type is modified, it will not affect the parsing of the PURL.If that is desired behaviour a new PURL Type and Namespace should be registered.