discovery

package
v0.2.10 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DiagnosticCodeCandidateTooLarge         = "artifact.discovery.candidate-too-large"
	DiagnosticCodeDecoderAmbiguous          = "artifact.discovery.decoder-ambiguous"
	DiagnosticCodeDecoderInvalidRecognition = "artifact.discovery.decoder-invalid-recognition"
	DiagnosticCodeDefinitionInvalid         = "artifact.discovery.definition-invalid"
	DiagnosticCodeResourceMissing           = "artifact.discovery.resource-missing"
	DiagnosticCodeSubresourceMissing        = "artifact.discovery.subresource-missing"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	SourceID            artifactstore.SourceID
	SourceKind          artifactstore.SourceKind
	Locator             artifactstore.Locator
	SourceContentDigest artifactstore.Digest
	Content             []byte
}

type Decoded

type Decoded struct {
	SubresourceLocator artifactstore.SubresourceLocator
	Definition         definition.Definition
	Diagnostics        []artifactstore.Diagnostic
}

type Decoder

type Decoder interface {
	ID() artifactstore.DecoderID
	Recognize(ctx context.Context, candidate Candidate) Recognition

	// Decode returns candidate-level diagnostics as its second result.
	//
	// Diagnostics attached to Decoded apply only to that emitted subresource.
	Decode(
		ctx context.Context,
		candidate Candidate,
	) ([]Decoded, []artifactstore.Diagnostic)
}

type DecoderRegistry

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

func NewDecoderRegistry

func NewDecoderRegistry(
	decoders ...Decoder,
) (*DecoderRegistry, error)

type DirectoryRoot

type DirectoryRoot struct {
	Root            artifactstore.Locator
	Recursive       bool
	IncludePatterns []string
}

type Engine

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

func NewEngine

func NewEngine(
	decoders *DecoderRegistry,
	clock artifactstore.Clock,
) (*Engine, error)

func (*Engine) Discover

func (e *Engine) Discover(
	ctx context.Context,
	rootID artifactstore.RootID,
	sourceID artifactstore.SourceID,
	sourceKind artifactstore.SourceKind,
	snapshot source.Snapshot,
	plan SourcePlan,
	previous []catalog.Occurrence,
) (Result, error)

type Plan

type Plan struct {
	Sources []SourcePlan
}

func (Plan) BySource

func (p Plan) BySource() map[artifactstore.SourceID]SourcePlan

func (Plan) Validate

func (p Plan) Validate() error

type Recognition

type Recognition int
const (
	RecognitionNone Recognition = iota
	RecognitionPossible
	RecognitionPreferred
)

type Result

type Result struct {
	Occurrences []catalog.Occurrence
	Definitions map[artifactstore.Digest]definition.Definition
	Diagnostics []artifactstore.Diagnostic
	Candidates  int
}

type SourcePlan

type SourcePlan struct {
	SourceID           artifactstore.SourceID
	ExplicitLocators   []artifactstore.Locator
	DirectoryRoots     []DirectoryRoot
	ExpectedGeneration string
	AllowedDecoderIDs  []artifactstore.DecoderID
	Authoritative      bool
	MaxCandidateBytes  int64
	MaxTotalBytes      int64
	MaxCandidates      int
	MaxEntries         int
	MaxDepth           int
}

func (SourcePlan) Normalized

func (p SourcePlan) Normalized() SourcePlan

Normalized returns an owned, deterministic copy with default limits.

It intentionally does not mutate the input plan or its backing slices.

func (SourcePlan) Validate

func (p SourcePlan) Validate() error

Jump to

Keyboard shortcuts

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