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:
- Detect version information from the custom binary
- Generate cache metadata based on detected version and build config
- Store the binary in the cache with proper permissions
- 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 ¶
func (u *ImportCustomBinaryUseCase) Execute( ctx context.Context, input *dto.CustomBinaryImportInput, ) (*dto.CustomBinaryImportResult, error)
Execute performs the custom binary import operation.
Flow:
- Validate input parameters
- Detect version and commit hash from binary
- Generate cache key from commit hash and build config
- Store binary in cache (copy + permissions + metadata)
- Set binary as active (create symlink)
- 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:
- Resolve the plugin name to a binary path
- Execute the binary with provided arguments
- 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 ¶
func (uc *PassthroughUseCase) Execute(ctx context.Context, req ExecuteRequest) (*ExecuteResponse, error)
Execute performs the binary passthrough operation.
Flow:
- Validate request
- Resolve plugin name to binary path
- Create passthrough command
- Execute the binary
- 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 ¶
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.