Documentation
¶
Overview ¶
Package objectstore implements protobom document storage on top of a generic object store (blob storage keyed by name). It is provider agnostic: concrete backends such as GCS or S3 supply an ObjectStore adapter and reuse the shared document store, key scheme and indexer defined here.
Index ¶
- Variables
- type Backend
- func (backend *Backend) FindDocumentIDsByHash(ctx context.Context, algorithm sbom.HashAlgorithm, value string) ([]string, error)
- func (backend *Backend) FindDocumentIDsByIdentifier(ctx context.Context, value string) ([]string, error)
- func (backend *Backend) FindDocumentIDsByName(ctx context.Context, name string) ([]string, error)
- func (backend *Backend) Retrieve(ctx context.Context, id string) (*sbom.Document, error)
- func (backend *Backend) Store(ctx context.Context, doc *sbom.Document, opts *storage.StoreOptions) error
- type Dimension
- type Indexer
- type ObjectStore
Constants ¶
This section is empty.
Variables ¶
var ErrMissingDocument = errors.New("document not found")
ErrMissingDocument is returned by Retrieve when no document matches the id.
var ErrObjectNotExist = errors.New("object does not exist")
ErrObjectNotExist is returned by ObjectStore.Get when the key does not exist. Adapters must translate their provider's not-found error into this sentinel.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend implements protobom document storage on top of an ObjectStore. It is provider agnostic; concrete backends (GCS, S3, ...) supply the ObjectStore.
func NewBackend ¶
func NewBackend(store ObjectStore, prefix string) *Backend
NewBackend returns a Backend that reads and writes objects through store, placing every key under the given prefix (which may be empty).
func (*Backend) FindDocumentIDsByHash ¶
func (backend *Backend) FindDocumentIDsByHash( ctx context.Context, algorithm sbom.HashAlgorithm, value string, ) ([]string, error)
FindDocumentIDsByHash returns the ids of documents that contain a node with the given hash.
func (*Backend) FindDocumentIDsByIdentifier ¶
func (backend *Backend) FindDocumentIDsByIdentifier(ctx context.Context, value string) ([]string, error)
FindDocumentIDsByIdentifier returns the ids of documents that contain a node with the given software identifier (purl, cpe or gitoid).
func (*Backend) FindDocumentIDsByName ¶
FindDocumentIDsByName returns the ids of documents that contain a node with the given name (matched case-insensitively).
func (*Backend) Store ¶
func (backend *Backend) Store(ctx context.Context, doc *sbom.Document, opts *storage.StoreOptions) error
Store serializes doc and writes it as a single object keyed by its document id. When opts.NoClobber is set and a document with that id already exists, it is left unchanged.
type Dimension ¶
type Dimension string
Dimension identifies a queryable attribute the Indexer maintains a secondary index for. Its value is used verbatim as a path segment in index keys.
const ( // DimensionIdentifier indexes Node.Identifiers values (purl, cpe, gitoid). DimensionIdentifier Dimension = "ident" // DimensionHash indexes Node.Hashes as "<algorithm-code>:<value>". DimensionHash Dimension = "hash" // DimensionName indexes the lower-cased Node.Name. DimensionName Dimension = "name" )
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer maintains document-granularity secondary indexes in an ObjectStore. Each entry is a marker object keyed "<prefix>/index/<dimension>/<value>/<document-id>", so a lookup is a list-by-prefix over "<prefix>/index/<dimension>/<value>/". It is reusable by any ObjectStore-backed backend.
func NewIndexer ¶
func NewIndexer(store ObjectStore, prefix string) *Indexer
NewIndexer returns an Indexer that writes and queries markers through store under prefix.
type ObjectStore ¶
type ObjectStore interface {
// Put writes data at key, overwriting any existing object.
Put(ctx context.Context, key string, data []byte) error
// Get returns the object at key, or ErrObjectNotExist if it does not exist.
Get(ctx context.Context, key string) ([]byte, error)
// Exists reports whether an object exists at key.
Exists(ctx context.Context, key string) (bool, error)
// List returns the keys of every object whose name starts with prefix.
List(ctx context.Context, prefix string) ([]string, error)
}
ObjectStore is the minimal object-storage abstraction the backend builds on. Keys are opaque, slash-delimited names; List matches by key prefix.