objects

package
v0.4.1 Latest Latest
Warning

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

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

Documentation

Overview

Package objects owns the values used to describe persisted DRS records and their checksum-derived views. It deliberately has no dependency on the generated HTTP contract: adapters translate at the boundary.

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 *Record) []string

AccessResources returns the normalized controlled-access resources attached to a record.

func CanonicalSHA256

func CanonicalSHA256(checksums []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 NormalizeChecksum

func NormalizeChecksum(cs string) string

func NormalizeChecksumType

func NormalizeChecksumType(checksumType string) string

func NormalizeNameAliases

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

func NormalizeSHA256Query

func NormalizeSHA256Query(value string) (string, bool)

func ParseHashQuery

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

func RecordHasChecksumTypeAndValue

func RecordHasChecksumTypeAndValue(obj Record, hashType, hashValue string) bool

func SHA256Values

func SHA256Values(checksums []Checksum) []string

func ValidateCanonicalSHA256

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

Types

type AccessAuthorizations

type AccessAuthorizations struct {
	BearerAuthIssuers   *[]string `json:"bearer_auth_issuers,omitempty"`
	DrsObjectId         *string   `json:"drs_object_id,omitempty"`
	PassportAuthIssuers *[]string `json:"passport_auth_issuers,omitempty"`
	SupportedTypes      *[]string `json:"supported_types,omitempty"`
}

AccessAuthorizations describes optional authorization issuers attached to an access method. The fields mirror the DRS contract without importing it.

type AccessMethod

type AccessMethod struct {
	AccessId       *string               `json:"access_id,omitempty"`
	AccessUrl      *AccessURL            `json:"access_url,omitempty"`
	Authorizations *AccessAuthorizations `json:"authorizations,omitempty"`
	Available      *bool                 `json:"available,omitempty"`
	Cloud          *string               `json:"cloud,omitempty"`
	Region         *string               `json:"region,omitempty"`
	Type           string                `json:"type"`
}

AccessMethod describes one physical access route for a record.

type AccessURL

type AccessURL struct {
	Headers *[]string `json:"headers,omitempty"`
	Url     string    `json:"url"`
}

AccessURL is the URL and optional request headers for one access method.

type Candidate

type Candidate struct {
	AccessMethods    *[]AccessMethod `json:"access_methods,omitempty"`
	Aliases          *[]string       `json:"aliases,omitempty"`
	Checksums        *[]Checksum     `json:"checksums,omitempty"`
	Contents         *[]Content      `json:"contents,omitempty"`
	ControlledAccess *[]string       `json:"controlled_access,omitempty"`
	Description      *string         `json:"description,omitempty"`
	MimeType         *string         `json:"mime_type,omitempty"`
	Name             *string         `json:"name,omitempty"`
	Size             *int64          `json:"size,omitempty"`
}

Candidate is the plain request value accepted by object registration and LFS metadata staging. HTTP adapters translate generated request models into this value before it crosses into core or persistence.

type CanonicalContent

type CanonicalContent struct {
	ContentID ContentID
	Record    Record
	Records   []Record
}

CanonicalContent is the prepared same-content view returned by checksum-aware reads. Record is the merged presentation and Records keeps the physical replicas available to callers that need them.

type Checksum

type Checksum struct {
	Type     string `json:"type"`
	Checksum string `json:"checksum"`
}

Checksum is the persistence-independent checksum value carried by a record.

func MergeAdditionalChecksums

func MergeAdditionalChecksums(existing, additions []Checksum) []Checksum

type Content

type Content struct {
	Contents *[]Content `json:"contents,omitempty"`
	DrsUri   *[]string  `json:"drs_uri,omitempty"`
	Id       *string    `json:"id,omitempty"`
	Name     string     `json:"name"`
}

Content is a nested bundle entry. It is intentionally independent of the generated API's ContentsObject so persistence and object services can share it without importing HTTP code.

type ContentID

type ContentID string

ContentID identifies content by its canonical checksum.

type Record

type Record struct {
	Id                    RecordID                   `json:"id"`
	AccessMethods         *[]AccessMethod            `json:"access_methods,omitempty"`
	Aliases               *[]string                  `json:"aliases,omitempty"`
	Authorizations        map[string][]string        `json:"-"`
	Checksums             []Checksum                 `json:"checksums"`
	Contents              *[]Content                 `json:"contents,omitempty"`
	ControlledAccess      *[]string                  `json:"controlled_access,omitempty"`
	CreatedTime           time.Time                  `json:"created_time"`
	Description           *string                    `json:"description,omitempty"`
	MimeType              *string                    `json:"mime_type,omitempty"`
	Name                  *string                    `json:"name,omitempty"`
	NameAliases           []string                   `json:"name_aliases,omitempty"`
	Properties            map[string]json.RawMessage `json:"-"`
	Project               string                     `json:"project"`
	PublicRead            bool                       `json:"-"`
	PublicReadPolicyKnown bool                       `json:"-"`
	SelfUri               string                     `json:"self_uri"`
	Size                  int64                      `json:"size"`
	UpdatedTime           *time.Time                 `json:"updated_time,omitempty"`
	Version               *string                    `json:"version,omitempty"`
}

Record is one physical object record. Extension fields are retained only while the value is in memory; SQL hydration preserves the historical behavior and does not claim to persist unknown properties.

func CandidateToRecord

func CandidateToRecord(c Candidate, now time.Time) (Record, error)

CandidateToRecord converts an HTTP-neutral registration candidate into a persisted record. Candidate.Contents is intentionally not copied: the historical catalog contract stores object contents separately from the registration record.

func EnforceCanonicalProjectScope

func EnforceCanonicalProjectScope(obj Record, organization, project string) (Record, error)

EnforceCanonicalProjectScope adds the exact project resource to a record's controlled-access set. It is the domain-side normalization used by record adapters before registration or overwrite.

func MergeRecordUpdate

func MergeRecordUpdate(existing Record, update Record, id string, now time.Time) (Record, error)

MergeRecordUpdate applies the mutable fields from update while retaining immutable identity and existing fields that were omitted by the caller.

type RecordID

type RecordID string

RecordID identifies one physical persisted record. Two records may refer to the same content while retaining distinct record IDs.

func MintRecordIDFromChecksum

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

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

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
}

RegistrationMergeInput is the state loaded by a content registration transaction and the metadata supplied by the incoming registration. Resource slices select metadata replacement semantics; authorization remains the caller's responsibility.

type RegistrationMergeResult

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

RegistrationMergeResult contains the merged metadata and, when needed, the name alias that must be inserted by the adapter. It is deliberately free of SQL, context, and authorization side effects.

func MergeRegistrationMetadata

func MergeRegistrationMetadata(input RegistrationMergeInput) RegistrationMergeResult

MergeRegistrationMetadata applies registration-specific merge semantics. This is intentionally separate from MergeRecordUpdate: registration may replace metadata only for one overlapping current resource, while ordinary record updates have different field and authorization semantics.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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