artifact

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdoptRequest

type AdoptRequest struct {
	Collection              collection.CollectionRef
	Occurrence              catalog.OccurrenceKey
	ExpectedCatalogRevision uint64
	Name                    string
	Enabled                 bool
	Data                    json.RawMessage
}

type AdoptionMode

type AdoptionMode string
const (
	AdoptionObserved AdoptionMode = "observed"
	AdoptionPinned   AdoptionMode = "pinned"
)

type Artifact

type Artifact struct {
	ID                 basespec.ArtifactID     `json:"id"`
	RootID             basespec.RootID         `json:"rootID"`
	CollectionID       basespec.CollectionID   `json:"collectionID"`
	Binding            SourceBinding           `json:"binding"`
	Kind               basespec.ArtifactKind   `json:"kind"`
	Name               string                  `json:"name"`
	Enabled            bool                    `json:"enabled"`
	Adoption           AdoptionMode            `json:"adoption"`
	ResolvedDefinition *cryptoutil.Digest      `json:"resolvedDefinition,omitempty"`
	Data               json.RawMessage         `json:"-"`
	State              State                   `json:"state"`
	Diagnostics        []diagnostic.Diagnostic `json:"diagnostics,omitempty"`
	Revision           uint64                  `json:"revision"`
	CreatedAt          time.Time               `json:"createdAt"`
	ModifiedAt         time.Time               `json:"modifiedAt"`
}

func (Artifact) Address

func (a Artifact) Address() ArtifactAddress

func (Artifact) Clone

func (a Artifact) Clone() Artifact

func (Artifact) Ref

func (a Artifact) Ref() ArtifactRef

func (Artifact) Validate

func (a Artifact) Validate() error

type ArtifactAddress

type ArtifactAddress struct {
	RootID       basespec.RootID       `json:"rootID"`
	CollectionID basespec.CollectionID `json:"collectionID"`
	ArtifactID   basespec.ArtifactID   `json:"artifactID"`
	Kind         basespec.ArtifactKind `json:"kind"`
}

func (ArtifactAddress) Validate

func (a ArtifactAddress) Validate() error

type ArtifactRef

type ArtifactRef struct {
	RootID     basespec.RootID     `json:"rootID"`
	ArtifactID basespec.ArtifactID `json:"artifactID"`
}

func (ArtifactRef) Validate

func (r ArtifactRef) Validate() error

type Draft

type Draft struct {
	Name    string
	Enabled bool
	Data    json.RawMessage
}

type PinRequest

type PinRequest struct {
	Collection                 collection.CollectionRef
	ExpectedCollectionRevision uint64
	Binding                    SourceBinding
	Name                       string
	Enabled                    bool
	Data                       json.RawMessage
}

type Policy

type Policy interface {
	Derive(
		ctx context.Context,
		value collection.Collection,
		occurrence catalog.Occurrence,
		def definition.Definition,
	) (Draft, bool, []diagnostic.Diagnostic)
}

type Reader

type Reader interface {
	Get(
		ctx context.Context,
		ref ArtifactRef,
	) (Artifact, error)

	ListByCollection(
		ctx context.Context,
		ref collection.CollectionRef,
	) ([]Artifact, error)

	ListSuppressions(
		ctx context.Context,
		ref collection.CollectionRef,
	) ([]Suppression, error)
}

type Reconciler

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

func NewReconciler

func NewReconciler(
	ids uuidutil.Generator,
	timeClock clockutil.Clock,
) (*Reconciler, error)

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(
	ctx context.Context,
	collectionValue collection.Collection,
	occurrences []catalog.Occurrence,
	existing []Artifact,
	suppressions []Suppression,
	definitions definition.Reader,
	policy Policy,
) (Reconciliation, error)

type Reconciliation

type Reconciliation struct {
	Creates     []Artifact
	Updates     []SourceStateUpdate
	Diagnostics []diagnostic.Diagnostic
}

type Repository

type Repository interface {
	Reader

	CreateAdopted(
		ctx context.Context,
		value Artifact,
		expectedCollectionRevision uint64,
		expectedCatalogRevision uint64,
	) error

	CreatePinned(
		ctx context.Context,
		value Artifact,
		expectedCollectionRevision uint64,
		expectedCatalogRevision uint64,
	) error

	Update(
		ctx context.Context,
		value Artifact,
		expectedRevision uint64,
	) error

	Unadopt(
		ctx context.Context,
		ref ArtifactRef,
		expectedRevision uint64,
		suppression *Suppression,
	) error

	Suppress(
		ctx context.Context,
		value Suppression,
		expectedCollectionRevision uint64,
	) error

	Unsuppress(
		ctx context.Context,
		ref collection.CollectionRef,
		binding SourceBinding,
		expectedRevision uint64,
	) error

	Purge(
		ctx context.Context,
		ref ArtifactRef,
		expectedRevision uint64,
	) error
}

type Service

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

func NewService

func NewService(
	repository Repository,
	collections collection.Reader,
	catalogs catalog.Reader,
	ids uuidutil.Generator,
	timeClock clockutil.Clock,
) (*Service, error)

func (*Service) Adopt

func (s *Service) Adopt(
	ctx context.Context,
	request AdoptRequest,
) (Artifact, error)

func (*Service) Get

func (s *Service) Get(
	ctx context.Context,
	ref ArtifactRef,
) (Artifact, error)

func (*Service) ListByCollection

func (s *Service) ListByCollection(
	ctx context.Context,
	ref collection.CollectionRef,
) ([]Artifact, error)

func (*Service) ListSuppressions

func (s *Service) ListSuppressions(
	ctx context.Context,
	ref collection.CollectionRef,
) ([]Suppression, error)

func (*Service) Move

func (*Service) Pin

func (s *Service) Pin(
	ctx context.Context,
	request PinRequest,
) (Artifact, error)

func (*Service) Purge

func (s *Service) Purge(
	ctx context.Context,
	ref ArtifactRef,
	expectedRevision uint64,
) error

Purge destructively removes one local Artifact Record.

Unlike Unadopt, Purge never creates a suppression. It does not remove externally owned Source content or immutable definitions.

func (*Service) SetEnabled

func (s *Service) SetEnabled(
	ctx context.Context,
	ref ArtifactRef,
	expectedRevision uint64,
	enabled bool,
) (Artifact, error)

func (*Service) Suppress

func (s *Service) Suppress(
	ctx context.Context,
	request SuppressRequest,
) (Suppression, error)

func (*Service) Unadopt

func (s *Service) Unadopt(
	ctx context.Context,
	ref ArtifactRef,
	expectedRevision uint64,
	suppress bool,
) error

func (*Service) Unsuppress

func (s *Service) Unsuppress(
	ctx context.Context,
	ref collection.CollectionRef,
	binding SourceBinding,
	expectedRevision uint64,
) error

func (*Service) UpdateData

func (s *Service) UpdateData(
	ctx context.Context,
	ref ArtifactRef,
	expectedRevision uint64,
	data json.RawMessage,
) (Artifact, error)

type SourceBinding

type SourceBinding struct {
	SourceID           basespec.SourceID           `json:"sourceID"`
	Locator            basespec.Locator            `json:"locator"`
	SubresourceLocator basespec.SubresourceLocator `json:"subresourceLocator,omitempty"`
	ExpectedKind       basespec.ArtifactKind       `json:"expectedKind"`
}

func (SourceBinding) Validate

func (b SourceBinding) Validate() error

type SourceStateUpdate

type SourceStateUpdate struct {
	ArtifactID         basespec.ArtifactID
	RootID             basespec.RootID
	CollectionID       basespec.CollectionID
	ResolvedDefinition *cryptoutil.Digest
	State              State
	Diagnostics        []diagnostic.Diagnostic
	Revision           uint64
	ModifiedAt         time.Time
	ExpectedRevision   uint64
}

func (SourceStateUpdate) Validate

func (u SourceStateUpdate) Validate() error

type State

type State string
const (
	StateAvailable    State = "available"
	StateMissing      State = "missing"
	StateInvalid      State = "invalid"
	StateIncompatible State = "incompatible"
)

func DeriveSourceState

func DeriveSourceState(
	current Artifact,
	occurrence *catalog.Occurrence,
) (
	*cryptoutil.Digest,
	State,
	[]diagnostic.Diagnostic,
	error,
)

DeriveSourceState derives only the source-owned fields of an existing Artifact from its current Collection occurrence.

It is shared by reconciliation and SQLite publication validation so a Publisher cannot apply a source-derived state transition that the Reconciler itself would never produce.

type SuppressRequest

type SuppressRequest struct {
	Collection                 collection.CollectionRef
	ExpectedCollectionRevision uint64
	Binding                    SourceBinding
}

type Suppression

type Suppression struct {
	RootID       basespec.RootID       `json:"rootID"`
	CollectionID basespec.CollectionID `json:"collectionID"`
	Binding      SourceBinding         `json:"binding"`
	Revision     uint64                `json:"revision"`
	CreatedAt    time.Time             `json:"createdAt"`
	ModifiedAt   time.Time             `json:"modifiedAt"`
}

func (Suppression) Validate

func (s Suppression) Validate() error

Jump to

Keyboard shortcuts

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