binary

package
v1.0.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecuteRequest

type ExecuteRequest struct {
	// PluginName is the name of the plugin whose binary will be used.
	// If empty, the active plugin binary will be used.
	PluginName string

	// Args are the arguments to pass to the binary.
	Args []string

	// WorkDir is the working directory for execution.
	// If empty, uses the current working directory.
	WorkDir string

	// Interactive indicates whether to run in interactive mode (with TTY).
	Interactive bool
}

ExecuteRequest contains the parameters for executing a binary passthrough.

type ExecuteResponse

type ExecuteResponse struct {
	// ExitCode is the exit code returned by the binary.
	ExitCode int

	// PluginName is the name of the plugin that was executed.
	PluginName string

	// BinaryPath is the path to the binary that was executed.
	BinaryPath string
}

ExecuteResponse contains the result of a binary passthrough execution.

type ImportCustomBinaryUseCase

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

ImportCustomBinaryUseCase orchestrates the import of a custom-built binary into the cache system. It coordinates between version detection, cache storage, and symlink management to:

  1. Detect version information from the custom binary
  2. Generate cache metadata based on detected version and build config
  3. Store the binary in the cache with proper permissions
  4. Activate the binary by creating a "current" symlink

This use case follows Clean Architecture principles:

  • Depends only on abstractions (ports interfaces)
  • Contains core business logic for binary import
  • Independent of infrastructure details (OS, filesystem, execution)

SOLID Compliance:

  • SRP: Single responsibility of importing custom binaries
  • OCP: Extensible via dependency injection without modification
  • LSP: Can be used wherever a binary import interface is expected
  • ISP: Depends only on necessary interfaces (detector, cache)
  • DIP: Depends on abstractions (BinaryVersionDetector, BinaryCache)

func NewImportCustomBinaryUseCase

func NewImportCustomBinaryUseCase(
	versionDetector ports.BinaryVersionDetector,
	binaryCache ports.BinaryCache,
	homeDir string,
	binaryName string,
) *ImportCustomBinaryUseCase

NewImportCustomBinaryUseCase creates a new ImportCustomBinaryUseCase.

Parameters:

  • versionDetector: Detector for extracting version info from binaries
  • binaryCache: Cache for storing and managing binaries
  • homeDir: User's home directory for cache paths
  • binaryName: Name of the binary (e.g., "stabled")

Returns:

  • *ImportCustomBinaryUseCase: Configured use case instance

func (*ImportCustomBinaryUseCase) Execute

Execute performs the custom binary import operation.

Flow:

  1. Validate input parameters
  2. Detect version and commit hash from binary
  3. Generate cache key from commit hash and build config
  4. Store binary in cache (copy + permissions + metadata)
  5. Set binary as active (create symlink)
  6. Return import result with cache information

Parameters:

  • ctx: Context for cancellation and timeout control
  • input: Import parameters including binary path, network type, build config

Returns:

  • *dto.CustomBinaryImportResult: Result containing cache paths and version info
  • error: If any step fails

Error Scenarios:

  • Binary execution fails or times out
  • Version output cannot be parsed
  • File copy fails (disk space, permissions)
  • Cache metadata write fails
  • Symlink creation fails

type PassthroughUseCase

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

PassthroughUseCase orchestrates the binary passthrough flow. It coordinates between BinaryResolver and BinaryExecutor to:

  1. Resolve the plugin name to a binary path
  2. Execute the binary with provided arguments
  3. Handle errors and return exit codes

This use case follows Clean Architecture principles:

  • Depends only on abstractions (ports interfaces)
  • Contains core business logic
  • Independent of infrastructure details

SOLID Compliance:

  • SRP: Single responsibility of orchestrating binary passthrough
  • DIP: Depends on abstractions (BinaryResolver, BinaryExecutor)
  • OCP: Can be extended without modification (e.g., add logging, metrics)

func NewPassthroughUseCase

func NewPassthroughUseCase(
	resolver ports.BinaryResolver,
	executor ports.BinaryExecutor,
) *PassthroughUseCase

NewPassthroughUseCase creates a new PassthroughUseCase.

Parameters:

  • resolver: Resolver for finding plugin binaries
  • executor: Executor for running binaries

Returns:

  • *PassthroughUseCase: Configured use case instance

func (*PassthroughUseCase) Execute

Execute performs the binary passthrough operation.

Flow:

  1. Validate request
  2. Resolve plugin name to binary path
  3. Create passthrough command
  4. Execute the binary
  5. Return result with exit code

Error Handling:

  • Returns error if plugin not found
  • Returns error if binary not cached/available
  • Returns error if binary execution fails to start
  • Returns exit code if binary runs but returns non-zero

func (*PassthroughUseCase) GetBinaryName

func (uc *PassthroughUseCase) GetBinaryName(ctx context.Context, pluginName string) (string, error)

GetBinaryName returns the binary name for a plugin. This is useful for command completion and help text.

func (*PassthroughUseCase) ListAvailablePlugins

func (uc *PassthroughUseCase) ListAvailablePlugins(ctx context.Context) ([]string, error)

ListAvailablePlugins returns all plugins that have binaries available. This is useful for command completion and help text.

Jump to

Keyboard shortcuts

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