handlers

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package handlers provides execution of handlers on a single pack. It encapsulates the flow: match files → filter handlers → create operations → execute.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHandler

func CreateHandler(name string, options map[string]interface{}) (interface{}, error)

CreateHandler creates a handler instance by name This replaces the registry-based handler creation

func ExecuteMatches

func ExecuteMatches(matches []rules.RuleMatch, dataStore datastore.DataStore, opts ExecutionOptions) (*context.ExecutionContext, error)

ExecuteMatches executes rule matches using handlers and the DataStore abstraction. This is the core execution function that replaces the internal pipeline approach.

func FilterMatchesByHandlerCategory

func FilterMatchesByHandlerCategory(matches []rules.RuleMatch, allowConfiguration, allowCodeExecution bool) []rules.RuleMatch

FilterMatchesByHandlerCategory filters rule matches based on handler category

func GetAllHandlerPatterns

func GetAllHandlerPatterns(pack types.Pack) (map[string][]string, error)

GetAllHandlerPatterns returns patterns for all available handlers in a pack Returns a map of handler name to list of patterns

func GetHandlerExecutionOrder

func GetHandlerExecutionOrder(handlerNames []string) []string

GetHandlerExecutionOrder returns handlers in the order they should be executed Code execution handlers run before configuration handlers

func GetHandlersNeedingFiles

func GetHandlersNeedingFiles(pack types.Pack, optionalFS ...types.FS) ([]string, error)

GetHandlersNeedingFiles returns handlers that have no matching files in the pack It uses the existing matching system to determine which handlers are already active Optionally accepts a filesystem parameter for testing

func GetMatches

func GetMatches(packs []types.Pack) ([]rules.RuleMatch, error)

GetMatches scans packs and returns all rule matches using the rule system

func GetMatchesFS

func GetMatchesFS(packs []types.Pack, fs types.FS) ([]rules.RuleMatch, error)

GetMatchesFS scans packs and returns all rule matches using the rule system with a custom filesystem This function is used for testing and commands that need to use a different filesystem

func GetPatternsForHandler

func GetPatternsForHandler(handlerName string, pack types.Pack) ([]string, error)

GetPatternsForHandler returns all patterns that would activate a specific handler This includes patterns from both global and pack-specific rules

func GroupMatchesByHandler

func GroupMatchesByHandler(matches []rules.RuleMatch) map[string][]rules.RuleMatch

GroupMatchesByHandler groups rule matches by their handler name

func SuggestFilenameForHandler

func SuggestFilenameForHandler(handlerName string, patterns []string) string

SuggestFilenameForHandler suggests a filename that would match the handler's patterns For glob patterns, it returns a reasonable example filename

Types

type ExecutionOptions

type ExecutionOptions struct {
	DryRun     bool
	Force      bool
	FileSystem types.FS
}

ExecutionOptions contains options for executing rule matches

type FilterType

type FilterType int

FilterType determines which handlers to execute

const (
	// ConfigOnly executes only configuration handlers (symlink, shell, path)
	ConfigOnly FilterType = iota
	// ProvisionOnly executes only code execution handlers (homebrew, install)
	ProvisionOnly
	// All executes all handlers
	All
)

type HandlerExecution

type HandlerExecution struct {
	HandlerName    string
	OperationCount int
	Success        bool
	Error          error
}

HandlerExecution represents the result of executing a single handler

type Options

type Options struct {
	DryRun     bool
	Force      bool
	FileSystem types.FS
	DataStore  datastore.DataStore
}

Options contains execution options for the handler pipeline

type Result

type Result struct {
	Pack             types.Pack
	TotalHandlers    int
	SuccessCount     int
	FailureCount     int
	SkippedCount     int
	ExecutedHandlers []HandlerExecution
}

Result contains the execution results for a single pack

func ExecuteHandlersForPack

func ExecuteHandlersForPack(pack types.Pack, filter FilterType, opts Options) (*Result, error)

ExecuteHandlersForPack executes the handler pipeline for a single pack. This is the minimal starting point that orchestrates existing code.

Jump to

Keyboard shortcuts

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