objects

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package objects owns the policies that normalize, identify, authorize, and merge generated DRS objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessMethodID

func AccessMethodID(accessType, accessURL string) string

AccessMethodID is stable for a type/URL pair and is safe to expose as the selector used by the DRS access endpoint.

func AccessResources

func AccessResources(obj *drs.DrsObject) []string

func CanonicalSHA256

func CanonicalSHA256(checksums []drs.Checksum) (string, bool)

func CleanToBasename

func CleanToBasename(name string) string

CleanToBasename extracts a portable basename from either Windows or Unix path syntax.

func LooksLikeSHA256

func LooksLikeSHA256(v string) bool

func MaterializeCandidate added in v0.4.2

func MaterializeCandidate(c drs.DrsObjectCandidate, now time.Time) (drs.DrsObject, error)

func MintRecordIDFromChecksum

func MintRecordIDFromChecksum(checksum string, authz []string) (string, error)

MintRecordIDFromChecksum returns a deterministic record ID for a checksum and one canonical project scope.

func NormalizeChecksumType

func NormalizeChecksumType(checksumType string) string

func NormalizeNameAliases

func NormalizeNameAliases(primary string, aliases []string) []string

func NormalizeOID added in v0.4.2

func NormalizeOID(oid string) string

func NormalizeRecord added in v0.4.2

func NormalizeRecord(record drs.DrsObject, fallback time.Time) (drs.DrsObject, error)

NormalizeRecord applies canonical identity, timestamp, name, checksum, access, and alias values.

func ParseHashQuery

func ParseHashQuery(rawHash string, rawType string) (string, string)

func RecordHasChecksumTypeAndValue

func RecordHasChecksumTypeAndValue(obj drs.DrsObject, hashType, hashValue string) bool

func ValidateCanonicalSHA256

func ValidateCanonicalSHA256(checksums []drs.Checksum) (string, bool, error)

Types

type AuthorizedScopePager added in v0.4.2

type AuthorizedScopePager interface {
	ListObjectIDsPageByAuthorizedScope(context.Context, string, string, string, int, int, []string, bool, bool) ([]string, error)
}

AuthorizedScopePager is an optional database capability. It allows the production store to apply authorization filters before paging, while alternate stores retain the materialized fallback in ListObjects.

type BulkOverwriteResult added in v0.4.2

type BulkOverwriteResult struct {
	Created         int
	Replaced        int
	DIDMatched      int
	ChecksumMatched int
}

BulkOverwriteResult summarizes a project-scoped, source-wins metadata copy.

type CanonicalRepair added in v0.4.2

type CanonicalRepair struct {
	Canonical    drs.DrsObject
	DuplicateIDs []string
}

CanonicalRepair describes one atomic repair of physical records that share a project-scoped checksum. Canonical remains a physical record; duplicate IDs become aliases after their rows are removed.

type ChecksumQuery added in v0.4.2

type ChecksumQuery struct {
	Type  string
	Value string
}

type ObjectStore added in v0.4.2

type ObjectStore interface {
	// GetObject resolves a physical ID or alias to its stored row.
	GetObject(context.Context, string) (*drs.DrsObject, error)
	GetBulkObjects(context.Context, []string) ([]drs.DrsObject, error)
	DeleteObject(context.Context, string) error
	BulkDeleteObjects(context.Context, []string) error
	RegisterObjects(context.Context, []drs.DrsObject) error
	RepairCanonicalDuplicates(context.Context, []CanonicalRepair) error
	ReplaceObjects(context.Context, []drs.DrsObject) error
	UpdateObjectAccessMethods(context.Context, string, []drs.AccessMethod) error
	BulkUpdateAccessMethods(context.Context, map[string][]drs.AccessMethod) error
	RemoveObjectControlledAccess(context.Context, string, string) error
	RemoveObjectControlledAccessBulk(context.Context, []string, string) (int, error)
	CreateObjectAlias(context.Context, string, string) error
	ResolveObjectAlias(context.Context, string) (string, error)
	GetObjectsByChecksums(context.Context, []string) (map[string][]drs.DrsObject, error)
	GetPublicReadByIDs(context.Context, []string) (map[string]bool, error)
	ListScopedObjectIDsByChecksums(context.Context, string, string, []string) (map[string][]string, error)
	ListObjectIDsByScope(context.Context, string, string) ([]string, error)
	ListObjectIDsByResources(context.Context, []string, bool) ([]string, error)
	ListObjectIDsPageByScope(context.Context, string, string, string, int, int) ([]string, error)
	ListObjectIDsPageByURL(context.Context, string, string, string, string, int, int, []string, bool, bool) ([]string, error)
}

ObjectStore is the persistence capability required by Service.

type RecordListQuery added in v0.4.2

type RecordListQuery struct {
	Scope          Scope
	Checksum       *ChecksumQuery
	ObjectURL      string
	StartAfter     string
	Limit          int
	Page           int
	RequiredMethod string
}

RecordListQuery describes the selection and pagination policy for a record listing.

type RegistrationMergeInput

type RegistrationMergeInput struct {
	ExistingName        string
	ExistingVersion     string
	ExistingDescription string
	ExistingSize        int64
	ExistingUpdated     time.Time
	IncomingName        string
	IncomingVersion     string
	IncomingDescription string
	IncomingSize        int64
	IncomingUpdated     time.Time
	IncomingResources   []string
	CurrentResources    []string
}

type RegistrationMergeResult

type RegistrationMergeResult struct {
	Name        string
	Version     string
	Description string
	Size        int64
	Updated     time.Time
	NameAlias   string
}

RegistrationMergeResult contains merged metadata and an optional name alias for the persistence write. It carries no SQL, context, or authorization state.

func MergeRegistrationMetadata

func MergeRegistrationMetadata(input RegistrationMergeInput) RegistrationMergeResult

MergeRegistrationMetadata applies registration-specific metadata replacement rules, including resource-overlap handling.

type Scope added in v0.4.2

type Scope struct {
	Organization string
	Project      string
}

Scope identifies the optional organization/project boundary for a record query or mutation. An empty Scope represents an unscoped operation.

func NewScope added in v0.4.2

func NewScope(organization, project string) (Scope, error)

NewScope validates and normalizes an organization/project scope. A project cannot be supplied without an organization; an omitted scope is valid.

type ScopedObject added in v0.4.2

type ScopedObject struct {
	Object drs.DrsObject
	Scope  Scope
}

ScopedObject is a registration candidate together with the project scope whose access claim must be materialized before registration.

type Service added in v0.4.2

type Service struct {
	// contains filtered or unexported fields
}

Service owns stateful object lookup and mutation operations.

func NewService added in v0.4.2

func NewService(store ObjectStore) *Service

func (*Service) BulkDeleteObjects added in v0.4.2

func (s *Service) BulkDeleteObjects(ctx context.Context, ids []string) error

func (*Service) BulkOverwriteObjects added in v0.4.2

func (s *Service) BulkOverwriteObjects(ctx context.Context, organization, project string, candidates []drs.DrsObject) (BulkOverwriteResult, error)

BulkOverwriteObjects replaces records from one project snapshot without canonicalizing checksum siblings. A checksum can therefore exist in more than one project, while still identifying an existing record in this scope.

func (*Service) BulkUpdateAccessMethodsAndRead added in v0.4.2

func (s *Service) BulkUpdateAccessMethodsAndRead(ctx context.Context, updates []drs.AccessMethodUpdate) ([]drs.DrsObject, error)

BulkUpdateAccessMethodsAndRead retains first-seen response order; the last update for a duplicate object ID wins.

func (*Service) CollapseProjectChecksumDuplicates added in v0.4.2

func (s *Service) CollapseProjectChecksumDuplicates(ctx context.Context, organization, project string) (int, error)

func (*Service) DeleteBulkByScope added in v0.4.2

func (s *Service) DeleteBulkByScope(ctx context.Context, organization, project string) (int, error)

func (*Service) DeleteObject added in v0.4.2

func (s *Service) DeleteObject(ctx context.Context, id string) error

func (*Service) DeleteObjectsByChecksums added in v0.4.2

func (s *Service) DeleteObjectsByChecksums(ctx context.Context, hashes []string) (int, error)

func (*Service) GetBulkObjects added in v0.4.2

func (s *Service) GetBulkObjects(ctx context.Context, ids []string, requiredMethod string) ([]drs.DrsObject, error)

func (*Service) GetObject added in v0.4.2

func (s *Service) GetObject(ctx context.Context, ident string, method string) (*drs.DrsObject, error)

GetObject retrieves the canonical record identified by ID, alias, or checksum and validates access.

func (*Service) GetObjectsByChecksums added in v0.4.2

func (s *Service) GetObjectsByChecksums(ctx context.Context, hashes []string, requiredMethod string) (map[string][]drs.DrsObject, error)

func (*Service) ListMissingScopedSHA256 added in v0.4.2

func (s *Service) ListMissingScopedSHA256(ctx context.Context, organization, project string, checksums []string) ([]string, error)

func (*Service) ListObjectIDsByScope added in v0.4.2

func (s *Service) ListObjectIDsByScope(ctx context.Context, organization, project string, requiredMethod string) ([]string, error)

func (*Service) ListObjects added in v0.4.2

func (s *Service) ListObjects(ctx context.Context, query RecordListQuery) ([]drs.DrsObject, error)

ListObjects returns one authorized page after project checksum-family merging.

func (*Service) ListPhysicalObjectsByScope added in v0.4.2

func (s *Service) ListPhysicalObjectsByScope(ctx context.Context, organization, project, requiredMethod string) ([]drs.DrsObject, error)

ListPhysicalObjectsByScope returns stored rows without checksum-family merging.

func (*Service) LookupChecksumQueries added in v0.4.2

func (s *Service) LookupChecksumQueries(ctx context.Context, queries []ChecksumQuery, requiredMethod string) ([][]drs.DrsObject, error)

LookupChecksumQueries preserves input order and duplicate queries.

func (*Service) RegisterCandidates added in v0.4.2

func (s *Service) RegisterCandidates(ctx context.Context, candidates []drs.DrsObjectCandidate) ([]drs.DrsObject, error)

RegisterCandidates materializes DRS candidates, persists them through the existing registration policy, and returns each durable record after applying the DRS read policy in request order.

func (*Service) RegisterObjects added in v0.4.2

func (s *Service) RegisterObjects(ctx context.Context, objs []drs.DrsObject) ([]drs.DrsObject, error)

RegisterObjects persists objects and returns their durable records in the same order as the submitted objects.

func (*Service) RegisterScopedObjects added in v0.4.2

func (s *Service) RegisterScopedObjects(ctx context.Context, candidates []ScopedObject) ([]drs.DrsObject, error)

RegisterScopedObjects canonicalizes project access, materializes timestamps, authorizes, and registers a batch of scoped objects in input order.

func (*Service) RemoveObjectControlledAccess added in v0.4.2

func (s *Service) RemoveObjectControlledAccess(ctx context.Context, objectID, resource string) (*drs.DrsObject, error)

func (*Service) UpdateAccessMethodsAndRead added in v0.4.2

func (s *Service) UpdateAccessMethodsAndRead(ctx context.Context, objectID string, methods []drs.AccessMethod) (*drs.DrsObject, error)

UpdateAccessMethodsAndRead updates one record and returns its durable, read-authorized representation.

func (*Service) UpdateObjectMetadata added in v0.4.2

func (s *Service) UpdateObjectMetadata(ctx context.Context, id string, update drs.DrsObject, scope Scope, explicitSize *int64) (drs.DrsObject, error)

Jump to

Keyboard shortcuts

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