types

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DuplicateChecker

type DuplicateChecker interface {
	// FilterDuplicates filters out duplicate records from the input channel.
	// It tracks total and skipped counts in the provided result.
	// Returns a channel with only non-duplicate records.
	FilterDuplicates(ctx context.Context, inputCh <-chan SourceItem, result *Result) <-chan SourceItem
}

DuplicateChecker is an interface for checking and filtering duplicate records. This allows filtering duplicates before transformation/enrichment.

type Enricher

type Enricher interface {
	// Enrich enriches a record with additional data.
	Enrich(ctx context.Context, inputCh <-chan *corev1.Record, result *Result) (<-chan *corev1.Record, <-chan error)
}

Enricher is an interface for enriching records with additional data.

type Fetcher

type Fetcher interface {
	// Fetch retrieves records from the external source and sends them to the output channel.
	// It should close the output channel when done and send any errors to the error channel.
	Fetch(ctx context.Context) (<-chan SourceItem, <-chan error)
}

Fetcher is an interface for fetching records from an external source. Each importer implements this interface to fetch data from their specific registry.

type ImportResult

type ImportResult struct {
	TotalRecords    int
	ImportedCount   int
	SkippedCount    int
	FailedCount     int
	Errors          []error
	OutputFile      string
	ImportedCIDs    []string
	ScannerFindings []string
}

ImportResult summarizes the outcome of an import operation.

type Importer

type Importer interface {
	Run(ctx context.Context) *ImportResult
	DryRun(ctx context.Context) *ImportResult
}

Importer defines the interface for importing records from external registries.

type Pusher

type Pusher interface {
	// Push pushes records to the destination and returns the result channel and error channel.
	Push(ctx context.Context, inputCh <-chan *corev1.Record) (<-chan *corev1.RecordRef, <-chan error)
}

Pusher is an interface for pushing records to the destination (DIR).

type Result

type Result struct {
	TotalRecords    int
	ImportedCount   int
	SkippedCount    int
	FailedCount     int
	Errors          []error
	ImportedCIDs    []string // CIDs of successfully imported records
	ScannerFindings []string
	Mu              sync.Mutex
}

Result contains the results of the pipeline execution.

func (*Result) IncrementFailedCount

func (r *Result) IncrementFailedCount()

IncrementFailedCount increments the failed record count (thread-safe).

func (*Result) RecordScannerFinding

func (r *Result) RecordScannerFinding(msg string)

RecordScannerFinding appends a scanner finding message (e.g. "record-name: error: message").

type Scanner

type Scanner interface {
	// Scan reads records from inputCh, runs the scanner per record, and sends records to the returned channel (may drop some).
	Scan(ctx context.Context, inputCh <-chan *corev1.Record, result *Result) (<-chan *corev1.Record, <-chan error)
}

Scanner is a pipeline stage that runs security scans between transform and push. It may drop records or append to result.ScannerFindings. Errors are sent to the returned errCh.

type SourceItem

type SourceItem struct {
	Kind  SourceKind
	MCP   mcpapiv0.ServerResponse
	A2A   *structpb.Struct
	Skill *structpb.Struct
}

SourceItem is one record from fetch through dedup before OASF transformation. SourceItem.Kind selects which field is valid.

func A2ASourceItem

func A2ASourceItem(card *structpb.Struct) SourceItem

A2ASourceItem wraps an AgentCard as structpb.Struct for the pipeline.

func AgentSkillSourceItem

func AgentSkillSourceItem(skill *structpb.Struct) SourceItem

AgentSkillSourceItem wraps a parsed Agent Skill payload for the pipeline.

func MCPSourceItem

func MCPSourceItem(s mcpapiv0.ServerResponse) SourceItem

MCPSourceItem wraps an MCP server response for the pipeline.

func (SourceItem) NameVersion

func (s SourceItem) NameVersion() string

NameVersion returns "name@version" for deduplication, or "" if it cannot be derived.

type SourceKind

type SourceKind int

SourceKind identifies which payload is set on SourceItem.

const (
	// SourceKindMCP is an MCP registry/listing payload ([mcpapiv0.ServerResponse]).
	SourceKindMCP SourceKind = iota
	// SourceKindA2A is an A2A AgentCard as [structpb.Struct] (JSON object).
	SourceKindA2A
	// SourceKindAgentSkill is a parsed Agent Skill as [structpb.Struct] (see importer/skill package contract).
	SourceKindAgentSkill
)

type Transformer

type Transformer interface {
	// Transform converts a source record to a target format.
	Transform(ctx context.Context, inputCh <-chan SourceItem, result *Result) (<-chan *corev1.Record, <-chan error)
}

Transformer is an interface for transforming records from one format to another. For example, converting MCP servers to OASF format.

Jump to

Keyboard shortcuts

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