gcs

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {

	// Options is the set of options for the GCS Backend.
	Options *BackendOptions
	// contains filtered or unexported fields
}

Backend implements the protobom/storage.Backend interface backed by Google Cloud Storage. It adapts a GCS bucket to the shared objectstore.Backend.

func NewBackend

func NewBackend(opts ...Option) *Backend

NewBackend creates a new GCS Backend, applying the given options on top of the defaults.

func (*Backend) CloseClient

func (backend *Backend) CloseClient() error

CloseClient closes the underlying storage client.

func (*Backend) FindDocumentIDsByHash

func (backend *Backend) FindDocumentIDsByHash(
	ctx context.Context, algorithm sbom.HashAlgorithm, value string,
) ([]string, error)

FindDocumentIDsByHash returns the ids of stored 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 stored 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 stored documents that contain a node with the given name (matched case-insensitively).

func (*Backend) InitClient

func (backend *Backend) InitClient() error

InitClient connects to Google Cloud Storage, optionally creates the target bucket and wires up the shared object-store backend.

func (*Backend) Retrieve

func (backend *Backend) Retrieve(id string, _ *storage.RetrieveOptions) (*sbom.Document, error)

Retrieve implements the storage.Retriever interface.

func (*Backend) Store

func (backend *Backend) Store(doc *sbom.Document, opts *storage.StoreOptions) error

Store implements the storage.Storer interface.

type BackendOptions

type BackendOptions struct {
	// Bucket is the name of the GCS bucket that holds the objects.
	Bucket string

	// Prefix is an optional object-key prefix applied to every key.
	Prefix string

	// ProjectID is the GCP project used when CreateBucket is set.
	ProjectID string

	// ClientOptions are passed through to the underlying storage client
	// (credentials, endpoints, ...). Leave empty to use default credentials.
	ClientOptions []option.ClientOption

	// CreateBucket creates the bucket on InitClient if it does not exist.
	CreateBucket bool
}

BackendOptions contains options specific to the protobom GCS backend. Field order is chosen to satisfy the fieldalignment linter.

func NewBackendOptions

func NewBackendOptions() *BackendOptions

NewBackendOptions creates a new, empty BackendOptions.

type Option

type Option func(*Backend)

Option represents a single configuration option for the GCS backend.

func WithBucket

func WithBucket(name string) Option

WithBucket sets the GCS bucket that holds the objects.

func WithClientOptions

func WithClientOptions(opts ...option.ClientOption) Option

WithClientOptions sets the options passed to the underlying storage client.

func WithCreateBucket

func WithCreateBucket(create bool) Option

WithCreateBucket configures whether InitClient creates the bucket if missing.

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix sets an object-key prefix applied to every stored key.

func WithProjectID

func WithProjectID(projectID string) Option

WithProjectID sets the GCP project used when creating the bucket.

Jump to

Keyboard shortcuts

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