ports

package
v0.3.5-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ports defines interfaces for infrastructure dependencies. These are the "ports" in hexagonal architecture - abstractions that the application layer depends on but doesn't implement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthProvider

type AuthProvider interface {
	// GetCredentials returns username and password for a registry.
	GetCredentials(ctx context.Context, registry string) (username, password string, err error)
}

AuthProvider retrieves authentication credentials for registries.

type CapabilityAnalyzer

type CapabilityAnalyzer interface {
	ExtractCapabilities(profile entities.ProfileReader) map[string][]capabilities.Capability
}

CapabilityAnalyzer extracts specific capability requirements from profiles. This allows the orchestrator to be tested with mock analyzers.

type CapabilityCollector

type CapabilityCollector interface {
	CollectRequiredCapabilities(ctx context.Context, profile entities.ProfileReader, runtime PluginRuntime, pluginDir string) (map[string][]capabilities.Capability, error)
}

CapabilityCollector collects required capabilities from plugins.

type CapabilityGatekeeperPort

type CapabilityGatekeeperPort interface {
	GrantCapabilities(
		required capabilities.Grant,
		capabilityInfo map[string]CapabilityInfo,
		trustAll bool,
	) (capabilities.Grant, error)
}

CapabilityGatekeeperPort grants capabilities based on security policy. Named with "Port" suffix to avoid collision with the concrete CapabilityGatekeeper type.

type CapabilityGranter

type CapabilityGranter interface {
	GrantCapabilities(ctx context.Context, required map[string][]capabilities.Capability, trustAll bool) (map[string][]capabilities.Capability, error)
}

CapabilityGranter grants capabilities (interactively or automatically).

type CapabilityInfo

type CapabilityInfo struct {
	ProfileSpecific *capabilities.Capability
	Capability      capabilities.Capability
	PluginName      string
	IsProfileBased  bool
	IsBroad         bool
}

CapabilityInfo contains metadata about a capability request.

type Closer

type Closer interface {
	io.Closer
}

Closer is a common interface for resources that need cleanup.

type DataRedactor

type DataRedactor interface {
	Redact(input string) string
}

DataRedactor scrubs sensitive information from output. Placed here as it's often used with execution/security components.

type EmbeddedPluginSource

type EmbeddedPluginSource interface {
	// Get returns the file path to an embedded plugin.
	// Returns empty string if not found.
	Get(name string) string

	// List returns names of all embedded plugins.
	List() []string
}

EmbeddedPluginSource provides access to built-in WASM plugins.

type EngineFactory

type EngineFactory interface {
	CreateEngine(ctx context.Context, profile entities.ProfileReader, grantedCaps map[string][]capabilities.Capability, pluginDir string, filters dto.FilterOptions, execution dto.ExecutionOptions, skipSchemaValidation bool) (ExecutionEngine, error)
}

EngineFactory creates execution engines with capabilities.

type ExecutionEngine

type ExecutionEngine interface {
	Execute(ctx context.Context, profile entities.ProfileReader) (*execution.ExecutionResult, error)
	Close(ctx context.Context) error
}

ExecutionEngine executes profiles and returns results.

type IntegrityVerifier

type IntegrityVerifier interface {
	// VerifySignature checks the signature of a plugin in the registry.
	VerifySignature(ctx context.Context, ref values.PluginReference) (*SignatureResult, error)

	// Sign signs a plugin artifact (for publishing).
	Sign(ctx context.Context, ref values.PluginReference) error
}

IntegrityVerifier verifies cryptographic signatures on plugin artifacts.

type LockfileRepository

type LockfileRepository interface {
	// Load reads a lockfile from the given path.
	// Returns nil, nil if lockfile doesn't exist.
	Load(ctx context.Context, path string) (*entities.Lockfile, error)

	// Save writes a lockfile to the given path.
	Save(ctx context.Context, lockfile *entities.Lockfile, path string) error

	// Exists checks if a lockfile exists at the given path.
	Exists(ctx context.Context, path string) (bool, error)
}

LockfileRepository handles lockfile persistence. This is a PORT - abstracts file system or other storage.

SOLID: Interface Segregation - focused only on lockfile I/O

type OutputFormatter

type OutputFormatter interface {
	Format(result *execution.ExecutionResult) error
}

OutputFormatter formats execution results.

type OutputFormatterFactory

type OutputFormatterFactory interface {
	// Create returns a formatter for the given format name.
	// options is implementation-specific (typically output.FactoryOptions).
	// Returns error if format is unknown.
	Create(format string, writer io.Writer, options interface{}) (OutputFormatter, error)

	// SupportedFormats returns list of available format names.
	SupportedFormats() []string
}

OutputFormatterFactory creates formatters by name. The options parameter is implementation-specific (e.g., output.FactoryOptions).

type OutputWriter

type OutputWriter interface {
	Write(ctx context.Context, data []byte, dest string) error
}

OutputWriter writes formatted output to destination.

type Plugin

type Plugin interface {
	// Describe returns plugin metadata including declared capabilities.
	Describe(ctx context.Context) (*PluginInfo, error)
}

Plugin represents a loaded WASM plugin that can be inspected and executed. This interface abstracts the concrete wasm.Plugin implementation.

type PluginDigester

type PluginDigester interface {
	// DigestBytes computes SHA-256 of raw bytes.
	DigestBytes(data []byte) string

	// DigestFile computes SHA-256 of a file.
	DigestFile(ctx context.Context, path string) (string, error)
}

PluginDigester computes digests for plugins. Separate from VersionResolver per Interface Segregation.

type PluginDirectoryResolver

type PluginDirectoryResolver interface {
	ResolvePluginDir(ctx context.Context) (string, error)
}

PluginDirectoryResolver resolves the plugin directory path.

type PluginInfo

type PluginInfo struct {
	Name         string
	Version      string
	Description  string
	Capabilities []capabilities.Capability
}

PluginInfo contains metadata about a plugin. This is the application-layer representation of plugin metadata.

type PluginRegistry

type PluginRegistry interface {
	// Pull downloads a plugin artifact from the registry.
	Pull(ctx context.Context, ref values.PluginReference) (*dto.PluginArtifactDTO, error)

	// Push uploads a plugin artifact to the registry.
	Push(ctx context.Context, artifact *dto.PluginArtifactDTO) error

	// Resolve resolves a reference to its content digest.
	Resolve(ctx context.Context, ref values.PluginReference) (values.Digest, error)
}

PluginRegistry provides access to remote OCI registries.

type PluginRepository

type PluginRepository interface {
	// Find retrieves a cached plugin by reference.
	Find(ctx context.Context, ref values.PluginReference) (*entities.Plugin, string, error)

	// Store persists a plugin with its WASM binary.
	// Returns the path to the stored WASM file.
	Store(ctx context.Context, plugin *entities.Plugin, wasm io.Reader) (string, error)

	// List returns all cached plugins.
	List(ctx context.Context) ([]*entities.Plugin, error)

	// Prune removes old versions, keeping only the specified number.
	Prune(ctx context.Context, keepVersions int) error

	// Delete removes a specific plugin from cache.
	Delete(ctx context.Context, ref values.PluginReference) error
}

PluginRepository manages persistent storage of cached plugins. Implements Repository pattern for Plugin aggregate.

type PluginRuntime

type PluginRuntime interface {
	// LoadPlugin compiles and caches a plugin from WASM bytes.
	LoadPlugin(ctx context.Context, name string, wasmBytes []byte) (Plugin, error)

	// Close releases runtime resources.
	Close(ctx context.Context) error
}

PluginRuntime abstracts the WASM runtime for plugin loading and management. This interface allows the application layer to work with plugins without depending on concrete infrastructure types like wasm.Runtime.

type PluginRuntimeFactory

type PluginRuntimeFactory interface {
	// NewRuntime creates a new plugin runtime with optional configuration.
	// Accepts functional options for capabilities, redaction, memory limits, and caching.
	NewRuntime(ctx context.Context, opts ...RuntimeOption) (PluginRuntime, error)
}

PluginRuntimeFactory creates runtime instances. This allows the application layer to create runtimes without importing infrastructure.

type ProfileLoader

type ProfileLoader interface {
	LoadProfile(path string) (*entities.Profile, error)
}

ProfileLoader loads profiles from storage.

type ProfileValidator

type ProfileValidator interface {
	Validate(profile *entities.Profile) error
	ValidateWithSchemas(ctx context.Context, profile *entities.Profile, runtime PluginRuntime) error
}

ProfileValidator validates profile structure and schemas.

type RuntimeOption

type RuntimeOption any

RuntimeOption configures runtime creation. This type alias allows the application layer to pass options without importing infrastructure.

type SecretResolver

type SecretResolver interface {
	// Resolve returns the secret value by name.
	// The resolved value is automatically tracked for redaction.
	Resolve(name string) (string, error)
}

SecretResolver resolves named secrets for profile interpolation. Implementations automatically track resolved values for redaction.

type SensitiveValueProvider

type SensitiveValueProvider interface {
	// Track registers a sensitive value to be protected (redacted).
	Track(value string)

	// AllValues returns all tracked sensitive values.
	AllValues() []string
}

SensitiveValueProvider tracks and provides all sensitive values for protection. This is a PORT - the application defines what it needs, infrastructure provides it.

type SignatureResult

type SignatureResult struct {
	SignedAt        time.Time
	Signer          string
	TransparencyLog string
	Certificate     []byte
	Verified        bool
}

SignatureResult contains signature verification details.

type SystemConfigProvider

type SystemConfigProvider interface {
	LoadConfig(ctx context.Context, path string) (*system.Config, error)
}

SystemConfigProvider loads system configuration.

type VersionResolver

type VersionResolver interface {
	// Resolve converts a version constraint to an exact version.
	// Examples:
	//   "@1.0"   -> "1.0.x" (latest 1.0.x)
	//   "^1.2.0" -> "1.x.x >= 1.2.0"
	//   "~1.2.3" -> "1.2.x >= 1.2.3"
	Resolve(constraint string, available []string) (string, error)
}

VersionResolver resolves semver version constraints to exact versions. This is a PORT - application defines what it needs, infrastructure provides how.

SOLID: Interface Segregation - focused only on version resolution

Jump to

Keyboard shortcuts

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