objectstore

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var ErrMissingDocument = errors.New("document not found")

ErrMissingDocument is returned by Retrieve when no document matches the id.

View Source
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

func (backend *Backend) FindDocumentIDsByName(ctx context.Context, name string) ([]string, error)

FindDocumentIDsByName returns the ids of documents that contain a node with the given name (matched case-insensitively).

func (*Backend) Retrieve

func (backend *Backend) Retrieve(ctx context.Context, id string) (*sbom.Document, error)

Retrieve reads and deserializes the document stored under id.

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.

func (*Indexer) FindDocumentIDs

func (indexer *Indexer) FindDocumentIDs(ctx context.Context, dimension Dimension, value string) ([]string, error)

FindDocumentIDs returns the ids of documents indexed under dimension=value.

func (*Indexer) Index

func (indexer *Indexer) Index(ctx context.Context, docID string, doc *sbom.Document) error

Index writes the secondary-index markers for a document. It is idempotent: re-indexing the same document rewrites the same (empty) marker objects.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL