storage

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CredentialReader

type CredentialReader interface {
	GetS3Credential(context.Context, string) (*buckets.Credential, error)
	ListS3Credentials(context.Context) ([]buckets.Credential, error)
}

type DeletePort

type DeletePort interface {
	DeleteExact(context.Context, []storage.DeleteTarget) error
}

type DeleteResult

type DeleteResult struct {
	ObjectURL string
	Status    string
	Error     string
}

type Dependencies

type Dependencies struct {
	Scopes         ScopeReader
	Credentials    CredentialReader
	Visibility     VisibilityReader
	Inventory      InventoryPort
	Probe          ProbePort
	Delete         DeletePort
	Physical       PhysicalScopeReader
	CleanupObjects ObjectScopeDeleter
	CleanupScopes  ScopeCatalog
}

type Error

type Error struct {
	Kind    ErrorKind
	Message string
	Cause   error
}

Error is a typed maintenance error. HTTP adapters map its Kind to status codes; domain callers can use errors.As without importing HTTP packages.

func (*Error) Error

func (e *Error) Error() string

func (*Error) ErrorCategory added in v0.4.1

func (e *Error) ErrorCategory() errorapi.ErrorCategory

func (*Error) ErrorCode added in v0.4.1

func (e *Error) ErrorCode() errorapi.ErrorCode

func (*Error) Is added in v0.4.1

func (e *Error) Is(target error) bool

func (*Error) PublicMessage added in v0.4.1

func (e *Error) PublicMessage() string

func (*Error) Unwrap added in v0.4.1

func (e *Error) Unwrap() error

type ErrorKind

type ErrorKind string
const (
	ErrorInvalidInput      ErrorKind = "invalid_input"
	ErrorScopeNotFound     ErrorKind = "scope_not_found"
	ErrorCredentialMissing ErrorKind = "credential_missing"
	ErrorPermissionDenied  ErrorKind = "permission_denied"
	ErrorObjectNotFound    ErrorKind = "object_not_found"
	ErrorBucketUnavailable ErrorKind = "bucket_unavailable"
	ErrorListingIncomplete ErrorKind = "listing_incomplete"
	ErrorUnsupported       ErrorKind = "unsupported"
)

type InspectRequest

type InspectRequest struct {
	ID                string
	Organization      string
	Project           string
	Key               string
	Scheme            string
	ObjectURL         string
	ExpectedSizeBytes *int64
	ExpectedSHA256    string
}

type InspectionMode

type InspectionMode string

InspectionMode controls the amount of inventory returned by InspectProjectStorage.

const (
	ModeItems   InspectionMode = "items"
	ModeExists  InspectionMode = "exists"
	ModeSummary InspectionMode = "summary"
)

type InspectionOptions

type InspectionOptions struct {
	Mode        InspectionMode
	IncludeHead bool
	PathPrefix  string
}

type InspectionResult

type InspectionResult struct {
	Summary Summary
	Items   []StorageObject
}

type Inspector

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

func (*Inspector) AuditProjectRecords

func (s *Inspector) AuditProjectRecords(ctx context.Context, organization, project, requestPrefix string) ([]ProjectRecordAudit, error)

AuditProjectRecords projects physical records for the project-record inspection route. Unlike prepared inventory reads, it intentionally keeps same-checksum physical duplicates visible and only emits records carrying a primary SHA-256 checksum.

func (*Inspector) InspectProjectStorage

func (s *Inspector) InspectProjectStorage(ctx context.Context, organization, project string, options InspectionOptions) (*InspectionResult, error)

InspectProjectStorage inventories the S3 target selected by the project's configured scope.

func (*Inspector) ListObjects

func (s *Inspector) ListObjects(ctx context.Context, organization, project string, includeHead bool) ([]StorageObject, error)

func (*Inspector) ProbeObject

func (s *Inspector) ProbeObject(ctx context.Context, request InspectRequest) (*ObjectMetadata, error)

func (*Inspector) ProbeObjects

func (s *Inspector) ProbeObjects(ctx context.Context, requests []InspectRequest) []ProbeResult

func (*Inspector) ResolvePathPrefix

func (s *Inspector) ResolvePathPrefix(ctx context.Context, organization, project, requestPrefix string) (string, error)

func (*Inspector) ValidateInventoryObjects

func (s *Inspector) ValidateInventoryObjects(ctx context.Context, requests []ListValidationRequest) []ListValidationResult

ValidateInventoryObjects compares requested physical S3 locations with inventory evidence. Exact targets are deduplicated, dense sibling keys are coalesced at the historical threshold, and output is always restored to input order including duplicate requests.

type InventoryOptions

type InventoryOptions struct {
	IncludeHead bool
	ExactPrefix bool
	MaxKeys     int32
}

type InventoryPort

type InventoryPort interface {
	Inventory(context.Context, storage.InventoryRequest) (storage.InventoryResult, error)
}

type ListValidationRequest

type ListValidationRequest struct {
	ID                string
	ObjectURL         string
	ExpectedSizeBytes *int64
	ExpectedName      string
}

type ListValidationResult

type ListValidationResult struct {
	ID                   string
	ObjectURL            string
	Provider             string
	Bucket               string
	Key                  string
	Path                 string
	Exists               bool
	Status               ProbeStatus
	Error                string
	ErrorKind            string
	SizeBytes            *int64
	ETag                 string
	LastModTime          time.Time
	ValidationStatus     ValidationStatus
	SizeMatch            *bool
	NameMatch            *bool
	ValidationMismatches []string
}

type ObjectMetadata

type ObjectMetadata struct {
	ObjectURL   string
	Provider    string
	Bucket      string
	Key         string
	Path        string
	SizeBytes   int64
	MetaSHA256  string
	ETag        string
	LastModTime time.Time
}

type ObjectScopeDeleter

type ObjectScopeDeleter interface {
	DeleteBulkByScope(context.Context, string, string) (int, error)
}

type PhysicalScopeReader

type PhysicalScopeReader interface {
	ListPhysicalObjectsByScope(context.Context, string, string, string) ([]objects.Record, error)
}

type ProbePort

type ProbePort interface {
	Probe(context.Context, []storage.ProbeTarget) []storage.ProbeResult
}

type ProbeResult

type ProbeResult struct {
	ID                   string
	ObjectURL            string
	Provider             string
	Bucket               string
	Key                  string
	Path                 string
	Exists               bool
	Status               ProbeStatus
	Error                string
	ErrorKind            string
	SizeBytes            *int64
	MetaSHA256           string
	ETag                 string
	LastModTime          time.Time
	ValidationStatus     ValidationStatus
	SizeMatch            *bool
	SHA256Match          *bool
	ValidationMismatches []string
}

type ProbeStatus

type ProbeStatus string
const (
	ProbePresent     ProbeStatus = "present"
	ProbeNotFound    ProbeStatus = "not_found"
	ProbeForbidden   ProbeStatus = "forbidden"
	ProbeInvalid     ProbeStatus = "invalid"
	ProbeUnsupported ProbeStatus = "unsupported"
	ProbeError       ProbeStatus = "error"
)

type ProjectAccessMethod

type ProjectAccessMethod struct {
	Type     string
	AccessID string
	URL      string
	Headers  []string
}

type ProjectCleanup

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

func (*ProjectCleanup) DeleteProjectData

func (s *ProjectCleanup) DeleteProjectData(ctx context.Context, organization, project string) (ProjectCleanupResult, error)

DeleteProjectData performs the project cleanup sequence: catalog objects are removed first, then matching bucket scopes are listed and deleted in repository order. A scope count includes only successful deletions.

func (*ProjectCleanup) DeleteProjectObjects

func (s *ProjectCleanup) DeleteProjectObjects(ctx context.Context, organization, project string, objectURLs []string) []DeleteResult

DeleteProjectObjects authorizes each URL against the resolved S3 scope, deduplicates in first-seen order, and dispatches exact physical URLs one at a time. This preserves per-item provider failures and retry ordering.

type ProjectCleanupResult

type ProjectCleanupResult struct {
	Organization        string
	ProjectID           string
	DeletedObjects      int
	DeletedBucketScopes int
}

ProjectCleanupResult is the plain result of deleting a project's catalog rows followed by its configured bucket scopes. HTTP adapters choose the wire representation.

type ProjectRecordAudit

type ProjectRecordAudit struct {
	ObjectID      string
	Checksum      string
	Organization  string
	Project       string
	Name          string
	Size          int64
	AccessURLs    []string
	AccessMethods []ProjectAccessMethod
	CreatedTime   time.Time
	UpdatedTime   *time.Time
}

ProjectRecordAudit is the plain projection used by project-record inspection. It intentionally retains physical duplicate rows and carries time values until the HTTP adapter chooses its wire format.

type ScopeCatalog

type ScopeCatalog interface {
	ListBucketScopes(context.Context) ([]buckets.Scope, error)
	DeleteBucketScope(context.Context, string, string, string, string) error
}

type ScopeReader

type ScopeReader interface {
	LookupBucketScope(context.Context, string, string) (buckets.Scope, bool, error)
}

type Service

type Service struct {
	*Inspector
	*ProjectCleanup
}

func NewService

func NewService(deps Dependencies) *Service

type StorageObject

type StorageObject struct {
	ObjectURL   string
	Provider    string
	Bucket      string
	Key         string
	Path        string
	SizeBytes   int64
	MetaSHA256  string
	ETag        string
	LastModTime time.Time
}

StorageObject is the provider-neutral inventory value exposed by this maintenance service. ObjectURL is always the canonical physical s3:// URL for project inventory.

type Summary

type Summary struct {
	Provider          string
	Bucket            string
	Prefix            string
	ObjectURL         string
	Exists            bool
	ObjectCount       int
	TotalBytes        int64
	ComputedAt        time.Time
	Mode              InspectionMode
	InventoryComplete bool
	InventoryWarning  string
}

type ValidationStatus

type ValidationStatus string
const (
	ValidationNotRequested ValidationStatus = "not_requested"
	ValidationMatched      ValidationStatus = "matched"
	ValidationMismatched   ValidationStatus = "mismatched"
	ValidationUnverifiable ValidationStatus = "unverifiable"
)

type VisibilityReader

type VisibilityReader interface {
	ListVisibleBuckets(context.Context) (map[string]buckets.VisibleBucket, error)
}

Jump to

Keyboard shortcuts

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