Documentation
¶
Index ¶
- Constants
- Variables
- func AvailableNodePackageManagers() []domain.PackageManagerType
- func AvailableSystemCacheTypes() []domain.CacheType
- func BuildFilterRepoCommand(ctx context.Context, args []string) *exec.Cmd
- func BuildToolTypeToStringSlice(types []domain.BuildToolType) []string
- func CacheTypeToLowerSlice(types []domain.CacheType) []string
- func CacheTypeToStringSlice(types []domain.CacheType) []string
- func CalculateBytesFreed(path string, cleanup func() error, verbose bool, cacheName string) (bytesFreed, beforeSize, afterSize int64)
- func CreateBooleanSettingsCleanerTestFunctions(t *testing.T, config BooleanSettingsCleanerTestConfig)
- func CreateBooleanSettingsTest(t *testing.T, config BooleanSettingsTestConfig)
- func DiskUsageBar(du DiskUsage, width int) string
- func FindGitRepositories(basePath string, maxDepth int) ([]string, error)
- func FormatDiskUsage(du DiskUsage) string
- func GetDirModTime(path string) time.Time
- func GetDirSize(path string) int64
- func GetFilesToRemoveFromSelection(allFiles []domain.GitHistoryFile, selectedIndices []int) []domain.GitHistoryFile
- func GetHomeDir() (string, error)
- func GetInstallHint() string
- func GetUniquePaths(files []domain.GitHistoryFile) []string
- func GinkgoAssertIsAvailableNoPanic(cleaner interface{ ... })
- func GinkgoAssertIsAvailableReturnsBoolean(cleaner interface{ ... })
- func GinkgoAssertIsAvailableWithCancelledContext(cleaner interface{ ... })
- func GinkgoAssertNameAndType(cleaner Cleaner, name string, expectedType domain.OperationType)
- func GinkgoAssertScanResultIsOk(scanResult result.Result[[]domain.ScanItem])
- func GinkgoErrorPropagationContext[T any](contextName string, itName string, setupError func(), ...)
- func GinkgoErrorPropagationTest[T any](setupError func(), operation func() result.Result[T])
- func GinkgoNoItemsToCleanTest(ctx context.Context, cleaner interface{ ... }, setupEmptyState func())
- func GinkgoNoItemsToScanTest(ctx context.Context, cleaner interface{ ... }, setupEmptyState func())
- func GinkgoValidateEmptySettingsContext(cleaner CleanerWithSettings, itName string)
- func GinkgoValidateEmptySettingsTest(cleaner CleanerWithSettings, itName string)
- func GinkgoValidateNilSettingsTest(cleaner CleanerWithSettings)
- func GinkgoValidateValidSettingsTest(cleaner CleanerWithSettings, settings *domain.OperationSettings)
- func NewCleanResultWithMetrics(itemsRemoved, itemsFailed int, bytesFreed int64, duration time.Duration) result.Result[domain.CleanResult]
- func NewDryRunCleanResult(itemCount int, totalBytes int64) result.Result[domain.CleanResult]
- func NewEmptyCleanResult() result.Result[domain.CleanResult]
- func NewTestCleaner[T any](constructor func(verbose, dryRun bool) T) func() T
- func NormalizePaths(paths []string) []string
- func PackageManagerTypeToLowerSlice(types []domain.PackageManagerType) []string
- func PackageManagerTypeToStringSlice(types []domain.PackageManagerType) []string
- func ParseDockerReclaimedSpace(output string) (int64, error)
- func ParseDockerSize(sizeStr string) (int64, error)
- func ParseNumberAndUnit(sizeStr string) (float64, string, error)
- func ResetDetector()
- func RunGetHomeDirTests(t *testing.T, testCases []GetHomeDirTestCase)
- func ScanVersionDirectory(ctx context.Context, versionsDir, managerName string, verbose bool) result.Result[[]domain.ScanItem]
- func StandardTestBinariesTotalSize() int64
- func TestAvailableTypesGeneric[T comparable](t *stdtesting.T, name string, getAvailable func() []T, expected []T)
- func TestBooleanSettingsCleanerCleanDryRun(t *testing.T, config BooleanSettingsCleanerTestConfig, ...)
- func TestBooleanSettingsCleanerValidateSettings(t *testing.T, config BooleanSettingsCleanerTestConfig, ...)
- func TestCleanDryRun(t *testing.T, newCleanerFunc SimpleCleanerConstructor, toolName string, ...)
- func TestCleanTiming(t *testing.T, newCleanerFunc SimpleCleanerConstructor, toolName string)
- func TestCleanTimingWithConstructor(t *testing.T, constructor SimpleCleanerConstructor, toolName string)
- func TestDryRunStrategy(t *testing.T, newCleanerFunc SimpleCleanerConstructor, toolName string)
- func TestDryRunStrategyWithConstructor(t *testing.T, constructor CleanerConstructorWithSettings, toolName string)
- func TestEnumString[T ~string](t *stdtesting.T, name string, values []T)
- func TestIsAvailable[T interface{ ... }](t *testing.T, newCleanerFunc func(bool, bool) T)
- func TestIsAvailableGeneric(t *testing.T, testCases []IsAvailableTestCase)
- func TestNewCleanerConstructor[T any](t *testing.T, constructor func(bool, bool) T, cleanerName string)
- func TestStandardCleaner(t *testing.T, constructor CleanerConstructorWithSettings, toolName string)
- func TestTypeString[T ~string](t *stdtesting.T, name string, cases []T)
- func TestTypeStringCases[T ~string](cases []T) []testing.ValueTestCase[T, string]
- func TestTypeStringGeneric[T ~string](t *stdtesting.T, name string, ...)
- func TestValidateSettings(t *testing.T, newCleanerFunc CleanerConstructorWithSettings, ...)
- func TrashPath(ctx context.Context, path string) error
- func ValidateBuildCacheSettings(settings *domain.OperationSettings) error
- func ValidateOptionalSettingsWithTypes[F any](settings *domain.OperationSettings, ...) error
- func ValidateSettingsWithTypes[S any](settings S, getSlice func(S) []string, availableTypes []string, ...) error
- func ValidateToolTypes(configuredTypes []string, availableTypes []string, typeName string) error
- type AgeBasedCleaner
- type AvailableCheckFunc
- type BinaryCategory
- type BinaryInfo
- type BinaryScanner
- type BinaryTrashOperator
- type BooleanSettingsCleanerTestConfig
- func NewBooleanSettingsCleanerTestConfig[T CleanerWithSettings](testName string, toolName string, settingsFieldName string, expectedItems uint, ...) BooleanSettingsCleanerTestConfig
- func NewBooleanSettingsCleanerTestConfigFn[T CleanerWithSettings](testName, toolName, settingsFieldName string, expectedItems uint, ...) BooleanSettingsCleanerTestConfig
- type BooleanSettingsTestConfig
- type BuildCacheCleaner
- func (bcc *BuildCacheCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (bcc *BuildCacheCleaner) IsAvailable(_ context.Context) bool
- func (bcc *BuildCacheCleaner) Name() string
- func (bcc *BuildCacheCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (bcc *BuildCacheCleaner) Type() domain.OperationType
- func (bcc *BuildCacheCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type CacheCleanerFunc
- type CargoCleaner
- func (cc *CargoCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (cc *CargoCleaner) IsAvailable(ctx context.Context) bool
- func (cc *CargoCleaner) Name() string
- func (cc *CargoCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (cc *CargoCleaner) Type() domain.OperationType
- func (cc *CargoCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type CleanItemFunc
- type CleanResultAnalyzer
- type CleanResultWithMetrics
- type CleanStats
- type Cleaner
- type CleanerBase
- type CleanerConstructorWithSettings
- func NewBooleanSettingsCleanerTestConstructor[T CleanerWithSettings](constructor func(verbose, dryRun bool) T) CleanerConstructorWithSettings
- func NewCleanerConstructorWithSettings[T CleanerWithSettings, M any](constructor func(verbose, dryRun bool, managers []M) T, ...) CleanerConstructorWithSettings
- type CleanerMetrics
- type CleanerWithSettings
- type CompiledBinariesCleaner
- func (c *CompiledBinariesCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (c *CompiledBinariesCleaner) GetStoreSize(ctx context.Context) int64
- func (c *CompiledBinariesCleaner) IsAvailable(ctx context.Context) bool
- func (c *CompiledBinariesCleaner) Name() string
- func (c *CompiledBinariesCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (c *CompiledBinariesCleaner) Type() domain.OperationType
- func (c *CompiledBinariesCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type CompiledBinariesOption
- type DiskUsage
- type DockerCleaner
- func (dc *DockerCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (dc *DockerCleaner) IsAvailable(ctx context.Context) bool
- func (dc *DockerCleaner) Name() string
- func (dc *DockerCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (dc *DockerCleaner) Type() domain.OperationType
- func (dc *DockerCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type DockerResourceType
- type ExecuteOptions
- type ExecutionMetrics
- type FileOperator
- type FilterRepoProvider
- type GetHomeDirTestCase
- type GitHistoryCleaner
- func (c *GitHistoryCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (c *GitHistoryCleaner) CreateBackup(ctx context.Context, backupPath string) error
- func (c *GitHistoryCleaner) EstimateImpact(ctx context.Context) (*ImpactEstimate, error)
- func (c *GitHistoryCleaner) GetSafetyReport(ctx context.Context) *domain.GitHistorySafetyReport
- func (c *GitHistoryCleaner) GetScanResult(ctx context.Context) (*domain.GitHistoryScanResult, error)
- func (c *GitHistoryCleaner) GetStoreSize(ctx context.Context) int64
- func (c *GitHistoryCleaner) IsAvailable(ctx context.Context) bool
- func (c *GitHistoryCleaner) Name() string
- func (c *GitHistoryCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (c *GitHistoryCleaner) SetSelectedFiles(files []domain.GitHistoryFile)
- func (c *GitHistoryCleaner) StripLargeBlobs(ctx context.Context, sizeMB int) error
- func (c *GitHistoryCleaner) Type() domain.OperationType
- func (c *GitHistoryCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type GitHistoryCleanerOption
- func WithGitHistoryCreateBackup(create bool) GitHistoryCleanerOption
- func WithGitHistoryDryRun(dryRun bool) GitHistoryCleanerOption
- func WithGitHistoryExcludeExtensions(exts []string) GitHistoryCleanerOption
- func WithGitHistoryExcludePaths(paths []string) GitHistoryCleanerOption
- func WithGitHistoryIncludeExtensions(exts []string) GitHistoryCleanerOption
- func WithGitHistoryMaxFiles(maxFiles int) GitHistoryCleanerOption
- func WithGitHistoryMinSizeMB(mb int) GitHistoryCleanerOption
- func WithGitHistoryRepoPath(path string) GitHistoryCleanerOption
- func WithGitHistorySelectedFiles(files []domain.GitHistoryFile) GitHistoryCleanerOption
- func WithGitHistoryVerbose(verbose bool) GitHistoryCleanerOption
- type GitHistoryExecutor
- func (e *GitHistoryExecutor) EstimateImpact(ctx context.Context, files []domain.GitHistoryFile) (*ImpactEstimate, error)
- func (e *GitHistoryExecutor) Execute(ctx context.Context, opts ExecuteOptions) (*domain.GitHistoryRewriteResult, error)
- func (e *GitHistoryExecutor) RemoveFilesFromHistory(ctx context.Context, paths []string) error
- func (e *GitHistoryExecutor) StripLargeBlobs(ctx context.Context, sizeMB int) error
- type GitHistoryExecutorOption
- type GitHistorySafetyChecker
- type GitHistoryScanner
- type GitHistoryScannerOption
- func WithExcludeExtensions(exts []string) GitHistoryScannerOption
- func WithExcludePaths(paths []string) GitHistoryScannerOption
- func WithIncludeExtensions(exts []string) GitHistoryScannerOption
- func WithMaxFiles(maxFiles int) GitHistoryScannerOption
- func WithMinSizeMB(mb int) GitHistoryScannerOption
- func WithVerbose(verbose bool) GitHistoryScannerOption
- type GoCacheCleaner
- type GoCacheType
- type GoCleaner
- func (gc *GoCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (gc *GoCleaner) IsAvailable(ctx context.Context) bool
- func (gc *GoCleaner) Name() string
- func (gc *GoCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (gc *GoCleaner) Type() domain.OperationType
- func (gc *GoCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type GoScanner
- type GolangciLintCacheCleaner
- func (glcc *GolangciLintCacheCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (glcc *GolangciLintCacheCleaner) IsAvailable(ctx context.Context) bool
- func (glcc *GolangciLintCacheCleaner) Name() string
- func (glcc *GolangciLintCacheCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (glcc *GolangciLintCacheCleaner) Type() domain.OperationType
- func (glcc *GolangciLintCacheCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type HomebrewCleaner
- func (hbc *HomebrewCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (hbc *HomebrewCleaner) IsAvailable(ctx context.Context) bool
- func (hbc *HomebrewCleaner) Name() string
- func (hbc *HomebrewCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (hbc *HomebrewCleaner) Type() domain.OperationType
- func (hbc *HomebrewCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type ImpactEstimate
- type IsAvailableConstructor
- type IsAvailableTestCase
- type JVMBuildToolType
- type MetricsCollector
- func (mc *MetricsCollector) GetMetrics(cleanerName string) (CleanerMetrics, bool)
- func (mc *MetricsCollector) RecordFailure(cleanerName string, startTime time.Time, err error)
- func (mc *MetricsCollector) RecordStart(cleanerName string) time.Time
- func (mc *MetricsCollector) RecordSuccess(cleanerName string, startTime time.Time, res domain.CleanResult)
- func (mc *MetricsCollector) Reset()
- func (mc *MetricsCollector) Snapshot() MetricsSnapshot
- type MetricsEnabledRegistry
- func (r *MetricsEnabledRegistry) CleanAllParallelWithMetrics(ctx context.Context, maxConcurrency int) map[string]CleanResultWithMetrics
- func (r *MetricsEnabledRegistry) CleanAllWithMetrics(ctx context.Context) map[string]result.Result[domain.CleanResult]
- func (r *MetricsEnabledRegistry) GetCollector() *MetricsCollector
- type MetricsSnapshot
- type NixCleaner
- func (nc *NixCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (nc *NixCleaner) CleanOldGenerations(ctx context.Context, keepCount int) result.Result[domain.CleanResult]
- func (nc *NixCleaner) GetStoreSize(ctx context.Context) int64
- func (nc *NixCleaner) IsAvailable(ctx context.Context) bool
- func (nc *NixCleaner) ListGenerations(ctx context.Context) result.Result[[]domain.NixGeneration]
- func (nc *NixCleaner) Name() string
- func (nc *NixCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (nc *NixCleaner) Type() domain.OperationType
- func (nc *NixCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type NixStoreSizer
- type NodePackageManagerCleaner
- func (npmc *NodePackageManagerCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (npmc *NodePackageManagerCleaner) IsAvailable(ctx context.Context) bool
- func (npmc *NodePackageManagerCleaner) Name() string
- func (npmc *NodePackageManagerCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (npmc *NodePackageManagerCleaner) Type() domain.OperationType
- func (npmc *NodePackageManagerCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type ParallelExecutor
- type ProjectExecutablesCleaner
- func (p *ProjectExecutablesCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (p *ProjectExecutablesCleaner) GetStoreSize(ctx context.Context) int64
- func (p *ProjectExecutablesCleaner) IsAvailable(ctx context.Context) bool
- func (p *ProjectExecutablesCleaner) IsExcludedByExtension(filename string) bool
- func (p *ProjectExecutablesCleaner) IsExcludedByPattern(filename string) bool
- func (p *ProjectExecutablesCleaner) Name() string
- func (p *ProjectExecutablesCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (p *ProjectExecutablesCleaner) Type() domain.OperationType
- func (p *ProjectExecutablesCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type ProjectExecutablesOption
- type ProjectInfo
- type ProjectLister
- type ProjectsManagementAutomationCleanerdeprecated
- func (pc *ProjectsManagementAutomationCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (pc *ProjectsManagementAutomationCleaner) IsAvailable(ctx context.Context) bool
- func (pc *ProjectsManagementAutomationCleaner) Name() string
- func (pc *ProjectsManagementAutomationCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (pc *ProjectsManagementAutomationCleaner) Type() domain.OperationType
- func (pc *ProjectsManagementAutomationCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type Registry
- func (r *Registry) Available(ctx context.Context) []Cleaner
- func (r *Registry) CleanAll(ctx context.Context) map[string]result.Result[domain.CleanResult]
- func (r *Registry) CleanAllParallel(ctx context.Context, maxConcurrency int) map[string]CleanResultWithMetrics
- func (r *Registry) Clear()
- func (r *Registry) Count() int
- func (r *Registry) Get(name string) (Cleaner, bool)
- func (r *Registry) List() []Cleaner
- func (r *Registry) Names() []string
- func (r *Registry) Register(name string, c Cleaner)
- func (r *Registry) Unregister(name string)
- type RemoveFunc
- type ScanDirectoryResult
- type ScanItemFunc
- type SimpleCleaner
- type SimpleCleanerConstructor
- type SizeEstimatorFunc
- type SystemCacheCleaner
- func (scc *SystemCacheCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (scc *SystemCacheCleaner) IsAvailable(_ context.Context) bool
- func (scc *SystemCacheCleaner) Name() string
- func (scc *SystemCacheCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (scc *SystemCacheCleaner) Type() domain.OperationType
- func (scc *SystemCacheCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type TempFilesCleaner
- func (tfc *TempFilesCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
- func (tfc *TempFilesCleaner) IsAvailable(ctx context.Context) bool
- func (tfc *TempFilesCleaner) Name() string
- func (tfc *TempFilesCleaner) Scan(ctx context.Context) result.Result[[]domain.ScanItem]
- func (tfc *TempFilesCleaner) Type() domain.OperationType
- func (tfc *TempFilesCleaner) ValidateSettings(settings *domain.OperationSettings) error
- type TrackedCleaner
- type ValidateSettingsTestCase
Constants ¶
const ( // DefaultMinSizeMB is the default minimum file size in MB for compiled binaries. DefaultMinSizeMB = 10 // DefaultOlderThan is the default age filter (0 = any age). DefaultOlderThan = "0" // DefaultCompiledBinariesTimeout is the default timeout for file operations. DefaultCompiledBinariesTimeout = 5 * time.Minute // MinAgeStringLength is the minimum length for age duration strings. MinAgeStringLength = 2 // DurationUnitDays represents days in hours. DurationUnitDays = 24 * time.Hour // DurationUnitWeeks represents weeks in hours. DurationUnitWeeks = 7 * 24 * time.Hour // DurationUnitMonths represents months in hours (30 days). DurationUnitMonths = 30 * 24 * time.Hour // DurationUnitYears represents years in hours. DurationUnitYears = 365 * 24 * time.Hour )
const ( // PercentConversionFactor converts fraction to percentage. PercentConversionFactor = 100 // DiskUsageHighThreshold is the threshold for high disk usage warning (in percent). DiskUsageHighThreshold = 90 )
Disk usage and formatting constants.
const ( // TestBinarySize1MB is the size of the first test binary in MB. TestBinarySize1MB = 20 // TestBinarySize2MB is the size of the second test binary in MB. TestBinarySize2MB = 15 // TestBinaryTotalSizeMB is the total size of test binaries in MB. TestBinaryTotalSizeMB = TestBinarySize1MB + TestBinarySize2MB )
Test binary size constants.
const ( // GitHistoryDefaultMinSizeMB is the default minimum file size in MB to consider. GitHistoryDefaultMinSizeMB = 1 // GitHistoryDefaultMaxFiles is the default maximum number of files to show. GitHistoryDefaultMaxFiles = 100 // GitHistoryDefaultMaxSearchDepth is the default maximum depth for repository search. GitHistoryDefaultMaxSearchDepth = 3 )
GitHistoryCleaner removes binary files from git history. This is a destructive operation that rewrites history.
const ( // FilterRepoTimeout is the timeout for git-filter-repo operations. FilterRepoTimeout = 10 * time.Minute // GarbageCollectionTimeout is the timeout for git garbage collection. GarbageCollectionTimeout = 5 * time.Minute // BackupTimeout is the timeout for creating repository backups. BackupTimeout = 5 * time.Minute // BytesPerMB is the number of bytes in a megabyte. BytesPerMB = 1024 * 1024 // DefaultPackRatio is the default pack file compression ratio estimate. DefaultPackRatio = 0.7 )
const ( // DryRunBytesPerItem is the estimated bytes freed per item in dry run mode when no size estimator is provided. DryRunBytesPerItem = 300 * 1024 * 1024 // 300MB per item // TrashPathTimeout is the timeout for trash operations. TrashPathTimeout = 30 * time.Second )
const ( // NixMockStoreSizeGB is the mock store size in GB for unavailable Nix. NixMockStoreSizeGB = 300 // NixMaxGenerationsToKeep is the maximum allowed generations to keep. NixMaxGenerationsToKeep = 10 // NixDryRunBytesPerGeneration is the estimated bytes freed per generation in dry-run mode. NixDryRunBytesPerGeneration = 50 * bytesPerMB )
const ( // DefaultProjectsAutomationTimeout is the default timeout for automation commands. DefaultProjectsAutomationTimeout = 2 * time.Minute // DefaultProjectsAutomationCacheSizeMB is the default cache size estimate in MB. DefaultProjectsAutomationCacheSizeMB = 100 )
const ( CleanerNix = "nix" CleanerHomebrew = "homebrew" CleanerDocker = "docker" CleanerCargo = "cargo" CleanerGo = "go" CleanerNode = "node" CleanerBuildCache = "buildcache" CleanerSystemCache = "systemcache" CleanerTempFiles = "tempfiles" CleanerProjects = "projects" CleanerProjectExec = "project-executables" CleanerCompiledBinaries = "compiled-binaries" CleanerGolangciLint = "golangci-lint-cache" )
Registry cleaner name constants. These are used for consistent naming across the codebase.
const DefaultNodePackageManagerTimeout = 2 * time.Minute
DefaultNodePackageManagerTimeout is the default timeout for package manager commands.
const DefaultProjectExecutablesTimeout = 2 * time.Minute
DefaultProjectExecutablesTimeout is the default timeout for project listing commands.
const (
// DockerParseTabSplitCount is the expected split count for parsing Docker output with tab delimiter.
DockerParseTabSplitCount = 2
)
const (
// HomebrewMinFieldsForVersion is the minimum number of fields needed to parse version info.
HomebrewMinFieldsForVersion = 2
)
const SafetyCheckTimeout = 30 * time.Second
SafetyCheckTimeout is the default timeout for safety checks.
Variables ¶
var ( ErrNoCacheTypeSpecified = errors.New("no cache type specified") ErrLintCacheNotImplemented = errors.New("lint cache cleaning not yet implemented") ErrGoCacheNotAvailable = errors.New("go not available") )
Sentinel errors for golang_cleaner.
var BuildCacheAvailableTypes = []string{ domain.BuildToolGo.String(), domain.BuildToolRust.String(), domain.BuildToolNode.String(), domain.BuildToolPython.String(), domain.BuildToolJava.String(), domain.BuildToolScala.String(), }
BuildCacheAvailableTypes defines all valid build cache tool types.
var DefaultExcludeBinaries = []string{
"chromedriver",
"geckodriver",
"edgedriver",
}
DefaultExcludeBinaries are specific binaries that should not be cleaned (required by tools).
var DefaultExcludeDirectories = []string{
"node_modules",
"venv",
".venv",
".terraform",
"__pycache__",
".git",
".hg",
".svn",
}
DefaultExcludeDirectories are directories that should never be scanned.
Functions ¶
func AvailableNodePackageManagers ¶
func AvailableNodePackageManagers() []domain.PackageManagerType
AvailableNodePackageManagers returns all available Node.js package managers.
func AvailableSystemCacheTypes ¶
AvailableSystemCacheTypes returns all available system cache types for the current platform.
func BuildFilterRepoCommand ¶
BuildFilterRepoCommand builds the command to run git-filter-repo with the given args.
func BuildToolTypeToStringSlice ¶
func BuildToolTypeToStringSlice(types []domain.BuildToolType) []string
BuildToolTypeToStringSlice converts domain.BuildToolType slice to string slice.
func CacheTypeToLowerSlice ¶
CacheTypeToLowerSlice converts domain.CacheType slice to lowercase string slice.
func CacheTypeToStringSlice ¶
CacheTypeToStringSlice converts domain.CacheType slice to string slice.
func CalculateBytesFreed ¶
func CalculateBytesFreed( path string, cleanup func() error, verbose bool, cacheName string, ) (bytesFreed, beforeSize, afterSize int64)
CalculateBytesFreed calculates the bytes freed from a directory after a cleanup operation. This consolidates the common pattern of: 1. Getting directory size before cleanup 2. Executing the cleanup function 3. Getting directory size after cleanup 4. Calculating the difference (bytes freed) 5. Logging verbose output if requested Returns the bytes freed (always non-negative), beforeSize, and afterSize for logging.
func CreateBooleanSettingsCleanerTestFunctions ¶
func CreateBooleanSettingsCleanerTestFunctions( t *testing.T, config BooleanSettingsCleanerTestConfig, )
CreateBooleanSettingsCleanerTestFunctions creates both ValidateSettings and Clean_DryRun test functions for cleaners with a boolean settings field. This eliminates duplicate config and constructor code.
Usage:
func TestXxxCleaner_BooleanSettingsTests(t *testing.T) {
CreateBooleanSettingsCleanerTestFunctions(t, BooleanSettingsCleanerTestFunctionsConfig{
TestName: "Xxx",
ToolName: "xxx-tool",
SettingsFieldName: "xxx settings",
CreateSettings: func(enabled bool) *domain.OperationSettings {
return &domain.OperationSettings{
XxxSettings: &domain.XxxSettings{
Enabled: enabled,
},
}
},
ExpectedItems: 1,
Constructor: NewBooleanSettingsCleanerTestConstructor(NewXxxCleaner),
})
}
func CreateBooleanSettingsTest ¶
func CreateBooleanSettingsTest(t *testing.T, config BooleanSettingsTestConfig)
CreateBooleanSettingsTest creates a test function for cleaners with boolean settings. This eliminates duplicate test function definitions across test files.
Usage:
func TestXxxCleaner_BooleanSettingsTests(t *testing.T) {
CreateBooleanSettingsTest(t, BooleanSettingsTestConfig{
TestName: "Xxx",
ToolName: "xxx-tool",
SettingsFieldName: "xxx settings",
ExpectedItems: 1,
Constructor: NewBooleanSettingsCleanerTestConstructor(NewXxxCleaner),
CreateSettingsFunc: func(enabled bool) *domain.OperationSettings {
return &domain.OperationSettings{
XxxSettings: &domain.XxxSettings{
Enabled: enabled,
},
}
},
})
}
func DiskUsageBar ¶
DiskUsageBar returns a visual bar representation of disk usage.
func FindGitRepositories ¶
FindGitRepositories finds all git repositories under the given base path.
func FormatDiskUsage ¶
FormatDiskUsage returns a formatted string showing disk usage like "229G 224G 4.8G 98%" Format: "total used free percent" all in human-readable format.
func GetDirModTime ¶
GetDirModTime returns the most recent modification time in directory.
func GetDirSize ¶
GetDirSize returns total size of directory recursively.
func GetFilesToRemoveFromSelection ¶
func GetFilesToRemoveFromSelection( allFiles []domain.GitHistoryFile, selectedIndices []int, ) []domain.GitHistoryFile
GetFilesToRemoveFromSelection filters scan results by user selection.
func GetInstallHint ¶
func GetInstallHint() string
GetInstallHint returns a hint for how to install git-filter-repo.
func GetUniquePaths ¶
func GetUniquePaths(files []domain.GitHistoryFile) []string
GetUniquePaths returns unique paths from files.
func GinkgoAssertIsAvailableNoPanic ¶
GinkgoAssertIsAvailableNoPanic asserts that calling IsAvailable does not panic. This eliminates duplicate test code across cleaner test files.
func GinkgoAssertIsAvailableReturnsBoolean ¶
GinkgoAssertIsAvailableReturnsBoolean verifies that IsAvailable returns a boolean value. This eliminates duplicate test code across cleaner test files.
func GinkgoAssertIsAvailableWithCancelledContext ¶
func GinkgoAssertIsAvailableWithCancelledContext(
cleaner interface{ IsAvailable(context.Context) bool },
)
GinkgoAssertIsAvailableWithCancelledContext tests that IsAvailable works with a cancelled context. This eliminates duplicate test code across cleaner test files.
func GinkgoAssertNameAndType ¶
func GinkgoAssertNameAndType(cleaner Cleaner, name string, expectedType domain.OperationType)
GinkgoAssertNameAndType tests that a cleaner returns the correct name and operation type. This eliminates duplicate name/type assertion code across multiple cleaner test files.
Parameters:
- name: Expected cleaner name (e.g., "compiled-binaries")
- expectedType: Expected operation type (e.g., domain.OperationTypeCompiledBinaries)
Usage:
ginkgo.It("should return correct name and type", func() {
GinkgoAssertNameAndType(cleaner, "compiled-binaries", domain.OperationTypeCompiledBinaries)
})
func GinkgoAssertScanResultIsOk ¶
GinkgoAssertScanResultIsOk verifies that a scan result is ok and the value is a slice of ScanItems. This eliminates duplicate scan result assertion code across multiple cleaner integration tests.
func GinkgoErrorPropagationContext ¶
func GinkgoErrorPropagationContext[T any]( contextName string, itName string, setupError func(), operation func() result.Result[T], )
GinkgoErrorPropagationContext creates a ginkgo.Context and ginkgo.It block for testing error propagation scenarios. This eliminates the duplicate Context/It wrapper pattern across multiple Ginkgo test files.
Parameters:
- contextName: The name for the ginkgo.Context (e.g., "when ListProjects fails")
- itName: The name for the ginkgo.It (e.g., "should return error when project listing fails")
- setupError: Function that sets up the mock to return an error
- operation: Function that performs the operation and returns a result
Usage:
GinkgoErrorPropagationContext(
"when ListProjects fails",
"should return error when project listing fails",
func() { mockLister.err = errors.New("failed to list projects") },
func() result.Result[[]domain.ScanItem] { return cleaner.Scan(ctx) },
)
func GinkgoErrorPropagationTest ¶
GinkgoErrorPropagationTest tests that errors from dependencies are properly propagated through Scan or Clean methods. This eliminates duplicate test code across multiple Ginkgo test files.
Parameters:
- setupError: Function that sets up the mock to return an error
- operation: Function that performs the operation (Scan or Clean) and returns a result
Usage:
ginkgo.Context("when ListProjects fails", func() {
ginkgo.It("should return error when project listing fails", func() {
GinkgoErrorPropagationTest(
func() { mockLister.err = errors.New("failed to list projects") },
func() result.Result[[]domain.ScanItem] { return cleaner.Scan(ctx) },
)
})
})
func GinkgoNoItemsToCleanTest ¶
func GinkgoNoItemsToCleanTest(ctx context.Context, cleaner interface { Clean(context.Context) result.Result[domain.CleanResult] }, setupEmptyState func(), )
GinkgoNoItemsToCleanTest tests the "no items to clean" scenario for Ginkgo-based cleaner tests. This eliminates duplicate test code across multiple Ginkgo test files.
Parameters:
- ctx: The test context
- cleaner: The cleaner instance to test (must have Clean method returning result.Result[domain.CleanResult])
- setupEmptyState: Function that sets up the mock to return empty results
Usage:
ginkgo.Context("with no items to clean", func() {
ginkgo.It("should return conservative result when no items found", func() {
GinkgoNoItemsToCleanTest(ctx, cleaner, func() {
mockScanner.binaries = []BinaryInfo{}
})
})
})
func GinkgoNoItemsToScanTest ¶
func GinkgoNoItemsToScanTest(ctx context.Context, cleaner interface { Scan(context.Context) result.Result[[]domain.ScanItem] }, setupEmptyState func(), )
GinkgoNoItemsToScanTest tests the "no items to scan" scenario for Ginkgo-based cleaner tests. This eliminates duplicate test code across multiple Ginkgo test files.
Parameters:
- ctx: The test context
- cleaner: The cleaner instance to test (must have Scan method returning result.Result[[]domain.ScanItem])
- setupEmptyState: Function that sets up the mock to return empty results
Usage:
ginkgo.Context("when no projects found", func() {
ginkgo.It("should return empty slice when no projects", func() {
GinkgoNoItemsToScanTest(ctx, cleaner, func() {
mockLister.projects = []ProjectInfo{}
})
})
})
func GinkgoValidateEmptySettingsContext ¶
func GinkgoValidateEmptySettingsContext(cleaner CleanerWithSettings, itName string)
GinkgoValidateEmptySettingsContext creates a ginkgo.Context and ginkgo.It block for testing that ValidateSettings returns no error for empty OperationSettings. This eliminates the duplicate Context wrapper pattern across multiple Ginkgo test files.
Parameters:
- cleaner: The cleaner instance with ValidateSettings method
- itName: The name for the ginkgo.It block (e.g., "should return nil when CompiledBinaries is nil")
Usage:
GinkgoValidateEmptySettingsContext(cleaner, "should return nil when CompiledBinaries is nil")
func GinkgoValidateEmptySettingsTest ¶
func GinkgoValidateEmptySettingsTest(cleaner CleanerWithSettings, itName string)
GinkgoValidateEmptySettingsTest tests that ValidateSettings returns no error for empty OperationSettings (no module-specific settings configured). This eliminates duplicate test code across multiple Ginkgo test files.
Parameters:
- cleaner: The cleaner instance with ValidateSettings method
- itName: The name for the ginkgo.It block (e.g., "should return nil when CompiledBinaries is nil")
Usage:
ginkgo.Context("with empty OperationSettings", func() {
GinkgoValidateEmptySettingsTest(cleaner, "should return nil when CompiledBinaries is nil")
})
func GinkgoValidateNilSettingsTest ¶
func GinkgoValidateNilSettingsTest(cleaner CleanerWithSettings)
GinkgoValidateNilSettingsTest tests that ValidateSettings returns no error for nil settings. This eliminates duplicate test code across multiple Ginkgo test files.
Parameters:
- cleaner: The cleaner instance with ValidateSettings method
Usage:
ginkgo.It("should return nil for nil settings", func() {
GinkgoValidateNilSettingsTest(cleaner)
})
func GinkgoValidateValidSettingsTest ¶
func GinkgoValidateValidSettingsTest( cleaner CleanerWithSettings, settings *domain.OperationSettings, )
GinkgoValidateValidSettingsTest tests that ValidateSettings returns no error for valid settings. This eliminates duplicate test code across multiple Ginkgo test files.
Parameters:
- cleaner: The cleaner instance with ValidateSettings method
- settings: The valid OperationSettings to validate
Usage:
ginkgo.It("should return nil for valid settings", func() {
settings := &domain.OperationSettings{
GitHistory: &domain.GitHistorySettings{
MaxFiles: 50,
},
}
GinkgoValidateValidSettingsTest(cleaner, settings)
})
func NewCleanResultWithMetrics ¶
func NewCleanResultWithMetrics( itemsRemoved, itemsFailed int, bytesFreed int64, duration time.Duration, ) result.Result[domain.CleanResult]
NewCleanResultWithMetrics returns a result with the given metrics.
func NewDryRunCleanResult ¶
NewDryRunCleanResult returns a dry-run result with the given item count and total bytes.
func NewEmptyCleanResult ¶
func NewEmptyCleanResult() result.Result[domain.CleanResult]
NewEmptyCleanResult returns a conservative result for when there are no items to clean.
func NewTestCleaner ¶
NewTestCleaner creates a cleaner with default test settings (verbose=false, dryRun=false).
func NormalizePaths ¶
NormalizePaths normalizes a slice of paths using filepath.Clean. This consolidates the common path normalization pattern used in multiple cleaners.
func PackageManagerTypeToLowerSlice ¶
func PackageManagerTypeToLowerSlice(types []domain.PackageManagerType) []string
PackageManagerTypeToLowerSlice converts domain.PackageManagerType slice to lowercase string slice.
func PackageManagerTypeToStringSlice ¶
func PackageManagerTypeToStringSlice(types []domain.PackageManagerType) []string
PackageManagerTypeToStringSlice converts domain.PackageManagerType slice to string slice.
func ParseDockerReclaimedSpace ¶
ParseDockerReclaimedSpace extracts "Total reclaimed space: X" from docker prune output. Returns 0 if no reclaimed space is found (which is valid).
func ParseDockerSize ¶
ParseDockerSize converts Docker size string to bytes. Supports units: B, kB, MB, GB, TB (case-insensitive).
func ParseNumberAndUnit ¶
ParseNumberAndUnit parses a size string like "2.5GB" into a number and unit. This consolidates the common fmt.Sscanf pattern used in multiple cleaners.
func RunGetHomeDirTests ¶
func RunGetHomeDirTests(t *testing.T, testCases []GetHomeDirTestCase)
RunGetHomeDirTests runs GetHomeDir tests for given test cases. This eliminates duplicate error checking code across GetHomeDir tests.
Usage:
func TestXxxCleaner_GetHomeDir(t *testing.T) {
testCases := []GetHomeDirTestCase{
{
Name: "with HOME set",
HomeValue: "/test/home",
WantErr: false,
WantHome: "/test/home",
},
{
Name: "fallback to USERPROFILE",
HomeValue: "",
ProfileValue: "C:\\Users\\test",
WantErr: false,
WantHome: "C:\\Users\\test",
},
}
RunGetHomeDirTests(t, testCases)
}
func ScanVersionDirectory ¶
func ScanVersionDirectory( ctx context.Context, versionsDir, managerName string, verbose bool, ) result.Result[[]domain.ScanItem]
ScanVersionDirectory scans a version directory for a language version manager. It returns scan items for each version subdirectory found.
func StandardTestBinariesTotalSize ¶
func StandardTestBinariesTotalSize() int64
StandardTestBinariesTotalSize returns the total size of StandardTestBinaries.
func TestAvailableTypesGeneric ¶
func TestAvailableTypesGeneric[T comparable]( t *stdtesting.T, name string, getAvailable func() []T, expected []T, )
TestAvailableTypesGeneric tests that the available types function returns the expected list.
func TestBooleanSettingsCleanerCleanDryRun ¶
func TestBooleanSettingsCleanerCleanDryRun( t *testing.T, config BooleanSettingsCleanerTestConfig, constructor CleanerConstructorWithSettings, )
TestBooleanSettingsCleanerCleanDryRun runs a standard Clean_DryRun test with expected items.
func TestBooleanSettingsCleanerValidateSettings ¶
func TestBooleanSettingsCleanerValidateSettings( t *testing.T, config BooleanSettingsCleanerTestConfig, constructor CleanerConstructorWithSettings, )
TestBooleanSettingsCleanerValidateSettings runs a standard ValidateSettings test for cleaners with a single boolean settings field. This eliminates duplicate test code across multiple files.
func TestCleanDryRun ¶
func TestCleanDryRun( t *testing.T, newCleanerFunc SimpleCleanerConstructor, toolName string, expectedItemsRemoved uint, )
TestCleanDryRun runs a standard clean dry-run test suite.
func TestCleanTiming ¶
func TestCleanTiming( t *testing.T, newCleanerFunc SimpleCleanerConstructor, toolName string, )
TestCleanTiming runs a standard clean timing test suite.
func TestCleanTimingWithConstructor ¶
func TestCleanTimingWithConstructor( t *testing.T, constructor SimpleCleanerConstructor, toolName string, )
TestCleanTimingWithConstructor is a helper that creates a Clean_Timing test.
func TestDryRunStrategy ¶
func TestDryRunStrategy(t *testing.T, newCleanerFunc SimpleCleanerConstructor, toolName string)
TestDryRunStrategy runs a standard dry-run strategy test suite.
func TestDryRunStrategyWithConstructor ¶
func TestDryRunStrategyWithConstructor( t *testing.T, constructor CleanerConstructorWithSettings, toolName string, )
TestDryRunStrategyWithConstructor is a helper that creates a DryRunStrategy test.
func TestEnumString ¶
func TestEnumString[T ~string](t *stdtesting.T, name string, values []T)
TestEnumString tests that all enum values produce their expected string representation This is a simpler alternative for types where the enum values are string constants.
func TestIsAvailable ¶
func TestIsAvailable[T interface {
IsAvailable(ctx context.Context) bool
}](t *testing.T, newCleanerFunc func(bool, bool) T)
TestIsAvailable is a helper that creates a standard IsAvailable test for cleaners. This eliminates duplicate test function code across multiple cleaner test files.
Usage:
func TestXxxCleaner_IsAvailable(t *testing.T) {
TestIsAvailable(t, NewXxxCleaner)
}
Type Parameters:
- T: The cleaner type that must implement IsAvailable
Parameters:
- t: The testing.T object
- newCleanerFunc: Function that creates a new cleaner instance with verbose and dryRun parameters
func TestIsAvailableGeneric ¶
func TestIsAvailableGeneric(t *testing.T, testCases []IsAvailableTestCase)
TestIsAvailableGeneric runs a standard IsAvailable test suite for cleaners that should always return a boolean value (true or false). This eliminates duplicate test code across multiple cleaner test files.
Parameters:
- t: The testing.T object
- testCases: Slice of IsAvailableTestCase containing test cases to run
func TestNewCleanerConstructor ¶
func TestNewCleanerConstructor[T any]( t *testing.T, constructor func(bool, bool) T, cleanerName string, )
TestNewCleanerConstructor tests a cleaner constructor function with different combinations of verbose and dryRun parameters. This eliminates duplicate test code across multiple cleaner test files.
Usage:
func TestNewXxxCleaner(t *testing.T) {
TestNewCleanerConstructor(t, NewXxxCleaner, "NewXxxCleaner")
}
Type Parameters:
- T: The cleaner type that must have verbose and dryRun fields
Parameters:
- t: The testing.T object
- constructor: Function that creates a cleaner with given verbose and dryRun flags
- cleanerName: Name of the cleaner for error messages
func TestStandardCleaner ¶
func TestStandardCleaner( t *testing.T, constructor CleanerConstructorWithSettings, toolName string, )
TestStandardCleaner is a helper that runs DryRunStrategy and Clean_Timing tests.
func TestTypeString ¶
func TestTypeString[T ~string](t *stdtesting.T, name string, cases []T)
TestTypeString tests the String() method of a type with the given cases.
func TestTypeStringCases ¶
func TestTypeStringCases[T ~string](cases []T) []testing.ValueTestCase[T, string]
TestTypeStringCases creates test cases for String() method testing.
func TestTypeStringGeneric ¶
func TestTypeStringGeneric[T ~string]( t *stdtesting.T, name string, getTestCases func() []testing.ValueTestCase[T, string], )
TestTypeStringGeneric tests the string representation of a type.
func TestValidateSettings ¶
func TestValidateSettings( t *testing.T, newCleanerFunc CleanerConstructorWithSettings, testCases []ValidateSettingsTestCase, )
TestValidateSettings runs a standard validation settings test suite.
func TrashPath ¶
TrashPath moves a file or directory to the system trash using the `trash` command. It applies a 30-second timeout to the operation. This is a shared helper to eliminate duplicate trash implementations across cleaners.
func ValidateBuildCacheSettings ¶
func ValidateBuildCacheSettings(settings *domain.OperationSettings) error
ValidateBuildCacheSettings validates build cache settings.
func ValidateOptionalSettingsWithTypes ¶
func ValidateOptionalSettingsWithTypes[F any]( settings *domain.OperationSettings, getField func(*domain.OperationSettings) *F, getSlice func(*F) []string, availableTypes []string, typeName string, ) error
ValidateOptionalSettingsWithTypes validates optional settings with type validation. It handles the common pattern of checking if a field is nil, and if not, validating its types against available types.
func ValidateSettingsWithTypes ¶
func ValidateSettingsWithTypes[S any]( settings S, getSlice func(S) []string, availableTypes []string, typeName string, ) error
ValidateSettingsWithTypes validates settings that have a types slice field. This is a generic helper to eliminate duplication across similar validators. The getter function extracts the types slice from the settings struct.
Types ¶
type AgeBasedCleaner ¶
type AgeBasedCleaner interface {
Cleaner
// SetMaxAge sets the maximum age for items to be considered for cleanup.
// Items older than this duration will be cleaned.
SetMaxAge(duration time.Duration)
// GetMaxAge returns the current maximum age setting.
GetMaxAge() time.Duration
// SupportsAgeFiltering returns true if this cleaner supports age-based filtering.
SupportsAgeFiltering() bool
}
AgeBasedCleaner extends Cleaner with age-based filtering capabilities. Cleaners that implement this interface can filter items by age during cleanup.
type AvailableCheckFunc ¶
AvailableCheckFunc is a function that checks if the cleaner is available.
type BinaryCategory ¶
type BinaryCategory string
BinaryCategory represents a category of compiled binaries to clean.
const ( CategoryTmp BinaryCategory = "tmp" CategoryTest BinaryCategory = "test" CategoryBin BinaryCategory = "bin" CategoryDist BinaryCategory = "dist" CategoryRoot BinaryCategory = "root" )
type BinaryInfo ¶
type BinaryInfo struct {
Path string
Size int64
ModTime time.Time
Category BinaryCategory
}
BinaryInfo represents information about a compiled binary.
func StandardTestBinaries ¶
func StandardTestBinaries() []BinaryInfo
StandardTestBinaries returns a slice of BinaryInfo for testing. This eliminates duplicate binary setup code across compiled binaries tests.
Returns two test binaries with sizes 20MB and 15MB respectively.
type BinaryScanner ¶
type BinaryScanner interface {
ScanDirectory(
ctx context.Context,
dir string,
categories []BinaryCategory,
minSize int64,
) ([]BinaryInfo, error)
}
BinaryScanner defines the interface for scanning compiled binaries.
type BinaryTrashOperator ¶
type BinaryTrashOperator interface {
TrashBinary(ctx context.Context, path string) error
GetFileSize(path string) int64
GetFileModTime(path string) (time.Time, error)
}
BinaryTrashOperator defines the interface for trashing binaries.
type BooleanSettingsCleanerTestConfig ¶
type BooleanSettingsCleanerTestConfig struct {
TestName string
ToolName string
SettingsFieldName string
CreateSettings func(bool) *domain.OperationSettings
ExpectedItems uint
Constructor CleanerConstructorWithSettings
}
BooleanSettingsCleanerTestConfig holds configuration for testing cleaners with a boolean settings field. Use this with TestBooleanSettingsCleanerValidateSettings and TestBooleanSettingsCleanerCleanDryRun.
func NewBooleanSettingsCleanerTestConfig ¶
func NewBooleanSettingsCleanerTestConfig[T CleanerWithSettings]( testName string, toolName string, settingsFieldName string, expectedItems uint, newCleanerFunc func(verbose, dryRun bool) T, createSettings func(bool) *domain.OperationSettings, ) BooleanSettingsCleanerTestConfig
NewBooleanSettingsCleanerTestConfig creates a BooleanSettingsCleanerTestConfig with standardized values.
func NewBooleanSettingsCleanerTestConfigFn ¶
func NewBooleanSettingsCleanerTestConfigFn[T CleanerWithSettings]( testName, toolName, settingsFieldName string, expectedItems uint, constructor func(verbose, dryRun bool) T, createSettings func(bool) *domain.OperationSettings, ) BooleanSettingsCleanerTestConfig
NewBooleanSettingsCleanerTestConfigFn creates a BooleanSettingsCleanerTestConfig from constructor and settings creation function.
type BooleanSettingsTestConfig ¶
type BooleanSettingsTestConfig struct {
TestName string
ToolName string
SettingsFieldName string
ExpectedItems uint
Constructor CleanerConstructorWithSettings
CreateSettingsFunc func(bool) *domain.OperationSettings
}
BooleanSettingsTestConfig holds all configuration needed to create a BooleanSettingsTests test function. Use CreateBooleanSettingsTest to generate the actual test function.
type BuildCacheCleaner ¶
type BuildCacheCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
BuildCacheCleaner handles build tool cache cleanup.
func NewBuildCacheCleaner ¶
func NewBuildCacheCleaner( verbose, dryRun bool, olderThan string, _, basePaths []string, ) (*BuildCacheCleaner, error)
NewBuildCacheCleaner creates build cache cleaner.
func (*BuildCacheCleaner) Clean ¶
func (bcc *BuildCacheCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean removes build tool caches.
func (*BuildCacheCleaner) IsAvailable ¶
func (bcc *BuildCacheCleaner) IsAvailable(_ context.Context) bool
IsAvailable checks if build cache cleaner is available.
func (*BuildCacheCleaner) Name ¶
func (bcc *BuildCacheCleaner) Name() string
Name returns the cleaner name for result tracking.
func (*BuildCacheCleaner) Type ¶
func (bcc *BuildCacheCleaner) Type() domain.OperationType
Type returns operation type for build cache cleaner.
func (*BuildCacheCleaner) ValidateSettings ¶
func (bcc *BuildCacheCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates build cache cleaner settings.
type CacheCleanerFunc ¶
type CacheCleanerFunc func(ctx context.Context, toolType JVMBuildToolType, homeDir string) result.Result[domain.CleanResult]
type CargoCleaner ¶
type CargoCleaner struct {
CleanerBase
}
func NewCargoCleaner ¶
func NewCargoCleaner(verbose, dryRun bool) *CargoCleaner
NewCargoCleaner creates Cargo cleaner.
func (*CargoCleaner) Clean ¶
func (cc *CargoCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean removes Cargo caches.
func (*CargoCleaner) IsAvailable ¶
func (cc *CargoCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if Cargo is available.
func (*CargoCleaner) Name ¶
func (cc *CargoCleaner) Name() string
Name returns the cleaner name for result tracking.
func (*CargoCleaner) Type ¶
func (cc *CargoCleaner) Type() domain.OperationType
Type returns operation type for Cargo cleaner.
func (*CargoCleaner) ValidateSettings ¶
func (cc *CargoCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates Cargo cleaner settings.
type CleanItemFunc ¶
type CleanItemFunc[T any] func(ctx context.Context, item T, homeDir string) result.Result[domain.CleanResult]
CleanItemFunc is a function that cleans a single item of type T.
type CleanResultAnalyzer ¶
type CleanResultAnalyzer struct {
// contains filtered or unexported fields
}
CleanResultAnalyzer provides methods for analyzing CleanResult in tests.
func NewCleanResultAnalyzer ¶
func NewCleanResultAnalyzer( t *testing.T, cleanResult domain.CleanResult, elapsed time.Duration, ) *CleanResultAnalyzer
NewCleanResultAnalyzer creates a new analyzer for the given CleanResult.
func (*CleanResultAnalyzer) VerifyTiming ¶
func (a *CleanResultAnalyzer) VerifyTiming()
VerifyTiming verifies that clean operation timing is correctly recorded.
type CleanResultWithMetrics ¶
type CleanResultWithMetrics struct {
Result result.Result[domain.CleanResult]
Duration time.Duration
Cleaner string
}
CleanResultWithMetrics wraps a clean result with execution metrics.
type CleanStats ¶
CleanStats tracks cleaning metrics.
type Cleaner ¶
type Cleaner interface {
// Name returns the unique identifier for this cleaner.
// Used for result tracking and registry operations.
Name() string
// Type returns the operation type for this cleaner.
// Used for categorization and filtering.
Type() domain.OperationType
// Clean executes the cleaning operation and returns the result.
Clean(ctx context.Context) result.Result[domain.CleanResult]
// IsAvailable checks if the cleaner can run on this system.
IsAvailable(ctx context.Context) bool
// Scan scans for cleanable items and returns them as scan items.
// This is used for dry-run estimation and preview functionality.
Scan(ctx context.Context) result.Result[[]domain.ScanItem]
}
Cleaner defines the interface for all cleaner implementations.
type CleanerBase ¶
type CleanerBase struct {
// contains filtered or unexported fields
}
CleanerBase holds the common fields shared by all cleaner implementations.
func NewCleanerBase ¶
func NewCleanerBase(verbose, dryRun bool) CleanerBase
NewCleanerBase creates a CleanerBase with the given settings.
func (CleanerBase) GetDryRun ¶
func (cb CleanerBase) GetDryRun() bool
GetDryRun returns the dryRun setting.
func (CleanerBase) GetVerbose ¶
func (cb CleanerBase) GetVerbose() bool
GetVerbose returns the verbose setting.
type CleanerConstructorWithSettings ¶
type CleanerConstructorWithSettings func(verbose, dryRun bool) CleanerWithSettings
CleanerConstructorWithSettings is a function type for creating cleaners in tests that need ValidateSettings.
func NewBooleanSettingsCleanerTestConstructor ¶
func NewBooleanSettingsCleanerTestConstructor[T CleanerWithSettings]( constructor func(verbose, dryRun bool) T, ) CleanerConstructorWithSettings
NewBooleanSettingsCleanerTestConstructor is a helper that creates a CleanerConstructorWithSettings from a cleaner constructor function.
func NewCleanerConstructorWithSettings ¶
func NewCleanerConstructorWithSettings[T CleanerWithSettings, M any]( constructor func(verbose, dryRun bool, managers []M) T, availableManagers func() []M, ) CleanerConstructorWithSettings
NewCleanerConstructorWithSettings creates a CleanerConstructorWithSettings from a constructor function that takes additional manager types parameter.
type CleanerMetrics ¶
type CleanerMetrics struct {
Name string
InvocationCount uint64
SuccessCount uint64
FailureCount uint64
TotalDuration time.Duration
TotalBytesFreed uint64
LastRunAt time.Time
LastError error
}
CleanerMetrics tracks metrics for a specific cleaner.
type CleanerWithSettings ¶
type CleanerWithSettings interface {
IsAvailable(ctx context.Context) bool
Clean(ctx context.Context) result.Result[domain.CleanResult]
ValidateSettings(*domain.OperationSettings) error
}
CleanerWithSettings represents a cleaner interface with settings validation This eliminates duplicate interface declarations in test helper functions.
type CompiledBinariesCleaner ¶
type CompiledBinariesCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
CompiledBinariesCleaner removes large compiled binary files that can be regenerated. It scans project directories for build outputs, test binaries, and distribution files.
func NewCompiledBinariesCleaner ¶
func NewCompiledBinariesCleaner( verbose, dryRun bool, minSizeMB int, olderThan string, basePaths, excludePatterns []string, opts ...CompiledBinariesOption, ) *CompiledBinariesCleaner
NewCompiledBinariesCleaner creates a new CompiledBinariesCleaner.
func (*CompiledBinariesCleaner) Clean ¶
func (c *CompiledBinariesCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean removes compiled binary files using trash.
func (*CompiledBinariesCleaner) GetStoreSize ¶
func (c *CompiledBinariesCleaner) GetStoreSize(ctx context.Context) int64
GetStoreSize returns the total size of all compiled binaries found.
func (*CompiledBinariesCleaner) IsAvailable ¶
func (c *CompiledBinariesCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if trash command is available.
func (*CompiledBinariesCleaner) Name ¶
func (c *CompiledBinariesCleaner) Name() string
Name returns the cleaner name for result tracking.
func (*CompiledBinariesCleaner) Scan ¶
Scan scans for compiled binary files in configured directories.
func (*CompiledBinariesCleaner) Type ¶
func (c *CompiledBinariesCleaner) Type() domain.OperationType
Type returns operation type for Compiled Binaries cleaner.
func (*CompiledBinariesCleaner) ValidateSettings ¶
func (c *CompiledBinariesCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates Compiled Binaries cleaner settings.
type CompiledBinariesOption ¶
type CompiledBinariesOption func(*CompiledBinariesCleaner)
CompiledBinariesOption is a functional option for configuring the cleaner.
func WithBasePaths ¶
func WithBasePaths(paths []string) CompiledBinariesOption
WithBasePaths sets the base paths to scan.
func WithBinaryScanner ¶
func WithBinaryScanner(scanner BinaryScanner) CompiledBinariesOption
WithBinaryScanner sets a custom scanner for testing.
func WithBinaryTrashOperator ¶
func WithBinaryTrashOperator(operator BinaryTrashOperator) CompiledBinariesOption
WithBinaryTrashOperator sets a custom trash operator for testing.
func WithIncludeCategories ¶
func WithIncludeCategories(categories []BinaryCategory) CompiledBinariesOption
WithIncludeCategories sets which binary categories to include.
type DiskUsage ¶
DiskUsage represents disk usage information for a filesystem.
func GetDiskUsage ¶
GetDiskUsage returns disk usage information for the filesystem containing path. Uses golang.org/x/sys/unix for cross-platform support.
type DockerCleaner ¶
type DockerCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
func NewDockerCleaner ¶
func NewDockerCleaner(verbose, dryRun bool, pruneMode domain.DockerPruneMode) *DockerCleaner
NewDockerCleaner creates Docker cleaner.
func (*DockerCleaner) Clean ¶
func (dc *DockerCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean removes Docker resources based on prune mode.
func (*DockerCleaner) IsAvailable ¶
func (dc *DockerCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if Docker is available.
func (*DockerCleaner) Name ¶
func (dc *DockerCleaner) Name() string
Name returns the unique identifier for this cleaner.
func (*DockerCleaner) Type ¶
func (dc *DockerCleaner) Type() domain.OperationType
Type returns operation type for Docker cleaner.
func (*DockerCleaner) ValidateSettings ¶
func (dc *DockerCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates Docker cleaner settings.
type DockerResourceType ¶
type DockerResourceType string
DockerResourceType represents Docker resource types for scanning.
type ExecuteOptions ¶
type ExecuteOptions struct {
FilesToRemove []domain.GitHistoryFile
CreateBackup bool
BackupPath string
SkipGC bool // Skip garbage collection (for testing)
}
ExecuteOptions configures the history rewrite.
type ExecutionMetrics ¶
type ExecutionMetrics struct {
TotalCleaners int
Successful int
Failed int
TotalDuration time.Duration
TotalBytesFreed int64
}
ExecutionMetrics provides aggregated metrics for parallel execution.
func CalculateMetrics ¶
func CalculateMetrics(results []CleanResultWithMetrics) ExecutionMetrics
CalculateMetrics aggregates metrics from parallel execution results.
type FileOperator ¶
type FileOperator interface {
FindExecutableFiles(dir string) ([]string, error)
TrashFile(ctx context.Context, path string) error
GetFileSize(path string) int64
}
FileOperator defines the interface for file operations. This interface enables mocking in tests.
type FilterRepoProvider ¶
type FilterRepoProvider int
FilterRepoProvider represents a way to run git-filter-repo.
const ( // FilterRepoNone indicates no provider is available. FilterRepoNone FilterRepoProvider = iota // FilterRepoSystem indicates git-filter-repo is installed system-wide. FilterRepoSystem // FilterRepoNix indicates we can use nix to run git-filter-repo. FilterRepoNix )
func DetectFilterRepoProvider ¶
func DetectFilterRepoProvider() FilterRepoProvider
DetectFilterRepoProvider detects how git-filter-repo can be run. Priority: system install > nix > none.
func (FilterRepoProvider) String ¶
func (p FilterRepoProvider) String() string
String returns the provider name.
type GetHomeDirTestCase ¶
type GetHomeDirTestCase struct {
Name string
HomeValue string
ProfileValue string
WantErr bool
WantHome string
}
GetHomeDirTestCase represents a test case for GetHomeDir tests.
type GitHistoryCleaner ¶
type GitHistoryCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
func NewGitHistoryCleaner ¶
func NewGitHistoryCleaner(opts ...GitHistoryCleanerOption) *GitHistoryCleaner
NewGitHistoryCleaner creates a new GitHistoryCleaner.
func (*GitHistoryCleaner) Clean ¶
func (c *GitHistoryCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean removes selected files from git history.
func (*GitHistoryCleaner) CreateBackup ¶
func (c *GitHistoryCleaner) CreateBackup(ctx context.Context, backupPath string) error
CreateBackup creates a backup of the repository.
func (*GitHistoryCleaner) EstimateImpact ¶
func (c *GitHistoryCleaner) EstimateImpact(ctx context.Context) (*ImpactEstimate, error)
EstimateImpact estimates the impact of removing the selected files.
func (*GitHistoryCleaner) GetSafetyReport ¶
func (c *GitHistoryCleaner) GetSafetyReport(ctx context.Context) *domain.GitHistorySafetyReport
GetSafetyReport returns the safety check report for the repository.
func (*GitHistoryCleaner) GetScanResult ¶
func (c *GitHistoryCleaner) GetScanResult( ctx context.Context, ) (*domain.GitHistoryScanResult, error)
GetScanResult performs a full scan and returns the result.
func (*GitHistoryCleaner) GetStoreSize ¶
func (c *GitHistoryCleaner) GetStoreSize(ctx context.Context) int64
GetStoreSize returns the size of the .git directory.
func (*GitHistoryCleaner) IsAvailable ¶
func (c *GitHistoryCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if git and git-filter-repo are available.
func (*GitHistoryCleaner) Name ¶
func (c *GitHistoryCleaner) Name() string
Name returns the cleaner name.
func (*GitHistoryCleaner) SetSelectedFiles ¶
func (c *GitHistoryCleaner) SetSelectedFiles(files []domain.GitHistoryFile)
SetSelectedFiles sets the files to remove.
func (*GitHistoryCleaner) StripLargeBlobs ¶
func (c *GitHistoryCleaner) StripLargeBlobs(ctx context.Context, sizeMB int) error
StripLargeBlobs removes all blobs larger than the specified size.
func (*GitHistoryCleaner) Type ¶
func (c *GitHistoryCleaner) Type() domain.OperationType
Type returns the operation type.
func (*GitHistoryCleaner) ValidateSettings ¶
func (c *GitHistoryCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates the cleaner settings.
type GitHistoryCleanerOption ¶
type GitHistoryCleanerOption func(*GitHistoryCleaner)
GitHistoryCleanerOption is a functional option for the cleaner.
func WithGitHistoryCreateBackup ¶
func WithGitHistoryCreateBackup(create bool) GitHistoryCleanerOption
WithGitHistoryCreateBackup sets whether to create a backup.
func WithGitHistoryDryRun ¶
func WithGitHistoryDryRun(dryRun bool) GitHistoryCleanerOption
WithGitHistoryDryRun sets dry run mode.
func WithGitHistoryExcludeExtensions ¶
func WithGitHistoryExcludeExtensions(exts []string) GitHistoryCleanerOption
WithGitHistoryExcludeExtensions sets extensions to exclude.
func WithGitHistoryExcludePaths ¶
func WithGitHistoryExcludePaths(paths []string) GitHistoryCleanerOption
WithGitHistoryExcludePaths sets path patterns to exclude.
func WithGitHistoryIncludeExtensions ¶
func WithGitHistoryIncludeExtensions(exts []string) GitHistoryCleanerOption
WithGitHistoryIncludeExtensions sets extensions to include.
func WithGitHistoryMaxFiles ¶
func WithGitHistoryMaxFiles(maxFiles int) GitHistoryCleanerOption
WithGitHistoryMaxFiles sets the maximum number of files to show.
func WithGitHistoryMinSizeMB ¶
func WithGitHistoryMinSizeMB(mb int) GitHistoryCleanerOption
WithGitHistoryMinSizeMB sets the minimum file size in MB.
func WithGitHistoryRepoPath ¶
func WithGitHistoryRepoPath(path string) GitHistoryCleanerOption
WithGitHistoryRepoPath sets the repository path.
func WithGitHistorySelectedFiles ¶
func WithGitHistorySelectedFiles(files []domain.GitHistoryFile) GitHistoryCleanerOption
WithGitHistorySelectedFiles sets the files selected for removal.
func WithGitHistoryVerbose ¶
func WithGitHistoryVerbose(verbose bool) GitHistoryCleanerOption
WithGitHistoryVerbose sets verbose mode.
type GitHistoryExecutor ¶
type GitHistoryExecutor struct {
CleanerBase
// contains filtered or unexported fields
}
GitHistoryExecutor executes git history rewrites using git-filter-repo.
func NewGitHistoryExecutor ¶
func NewGitHistoryExecutor( repoPath string, verbose, dryRun bool, opts ...GitHistoryExecutorOption, ) *GitHistoryExecutor
NewGitHistoryExecutor creates a new executor.
func (*GitHistoryExecutor) EstimateImpact ¶
func (e *GitHistoryExecutor) EstimateImpact( ctx context.Context, files []domain.GitHistoryFile, ) (*ImpactEstimate, error)
EstimateImpact estimates the impact of removing files without executing.
func (*GitHistoryExecutor) Execute ¶
func (e *GitHistoryExecutor) Execute( ctx context.Context, opts ExecuteOptions, ) (*domain.GitHistoryRewriteResult, error)
Execute runs the history rewrite.
func (*GitHistoryExecutor) RemoveFilesFromHistory ¶
func (e *GitHistoryExecutor) RemoveFilesFromHistory(ctx context.Context, paths []string) error
RemoveFilesFromHistory is a convenience method that combines scanning and removal.
func (*GitHistoryExecutor) StripLargeBlobs ¶
func (e *GitHistoryExecutor) StripLargeBlobs(ctx context.Context, sizeMB int) error
StripLargeBlobs removes all blobs larger than the specified size.
type GitHistoryExecutorOption ¶
type GitHistoryExecutorOption func(*GitHistoryExecutor)
GitHistoryExecutorOption is a functional option for the executor.
func WithPackRatio ¶
func WithPackRatio(ratio float64) GitHistoryExecutorOption
WithPackRatio sets the pack file compression ratio for size estimation.
type GitHistorySafetyChecker ¶
type GitHistorySafetyChecker struct {
// contains filtered or unexported fields
}
GitHistorySafetyChecker performs safety checks before rewriting git history.
func NewGitHistorySafetyChecker ¶
func NewGitHistorySafetyChecker(repoPath string, verbose bool) *GitHistorySafetyChecker
NewGitHistorySafetyChecker creates a new safety checker.
func (*GitHistorySafetyChecker) Check ¶
func (c *GitHistorySafetyChecker) Check(ctx context.Context) *domain.GitHistorySafetyReport
Check performs all safety checks and returns a report.
func (*GitHistorySafetyChecker) CreateBackup ¶
func (c *GitHistorySafetyChecker) CreateBackup(ctx context.Context, backupPath string) error
CreateBackup creates a backup of the repository.
type GitHistoryScanner ¶
type GitHistoryScanner struct {
// contains filtered or unexported fields
}
GitHistoryScanner scans git history for large binary files.
func NewGitHistoryScanner ¶
func NewGitHistoryScanner(repoPath string, opts ...GitHistoryScannerOption) *GitHistoryScanner
NewGitHistoryScanner creates a new git history scanner.
func (*GitHistoryScanner) GetRepoSize ¶
func (s *GitHistoryScanner) GetRepoSize() (int64, error)
GetRepoSize returns the size of the .git directory.
func (*GitHistoryScanner) Scan ¶
func (s *GitHistoryScanner) Scan(ctx context.Context) (*domain.GitHistoryScanResult, error)
Scan scans git history for large binary files.
type GitHistoryScannerOption ¶
type GitHistoryScannerOption func(*GitHistoryScanner)
GitHistoryScannerOption is a functional option for the scanner.
func WithExcludeExtensions ¶
func WithExcludeExtensions(exts []string) GitHistoryScannerOption
WithExcludeExtensions sets extensions to exclude.
func WithExcludePaths ¶
func WithExcludePaths(paths []string) GitHistoryScannerOption
WithExcludePaths sets path patterns to exclude.
func WithIncludeExtensions ¶
func WithIncludeExtensions(exts []string) GitHistoryScannerOption
WithIncludeExtensions sets extensions to include (only these will be found).
func WithMaxFiles ¶
func WithMaxFiles(maxFiles int) GitHistoryScannerOption
WithMaxFiles sets the maximum number of files to return.
func WithMinSizeMB ¶
func WithMinSizeMB(mb int) GitHistoryScannerOption
WithMinSizeMB sets the minimum file size in MB.
func WithVerbose ¶
func WithVerbose(verbose bool) GitHistoryScannerOption
WithVerbose sets verbose mode.
type GoCacheCleaner ¶
type GoCacheCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
GoCacheCleaner handles built-in Go cache cleaning operations.
func NewGoCacheCleaner ¶
func NewGoCacheCleaner(cacheType GoCacheType, verbose, dryRun bool) *GoCacheCleaner
NewGoCacheCleaner creates a new GoCacheCleaner.
func (*GoCacheCleaner) Clean ¶
func (gcc *GoCacheCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean cleans the specified cache type.
func (*GoCacheCleaner) IsAvailable ¶
func (gcc *GoCacheCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if the Go cache cleaner is available. It verifies that the Go command is installed and accessible.
func (*GoCacheCleaner) Name ¶
func (gcc *GoCacheCleaner) Name() string
Name returns the cleaner name for result tracking.
type GoCacheType ¶
type GoCacheType uint16
GoCacheType represents a type-safe enum for Go cache flags. It uses bit flags so multiple cache types can be combined.
const ( // GoCacheNone represents no cache types - invalid state. GoCacheNone GoCacheType = 0 // GoCacheGOCACHE represents the main Go cache (GOCACHE). GoCacheGOCACHE GoCacheType = 1 << iota // GoCacheTestCache represents the Go test cache (GOTESTCACHE). GoCacheTestCache // GoCacheModCache represents the Go module cache (GOMODCACHE). GoCacheModCache // GoCacheBuildCache represents the Go build cache folders (go-build*). GoCacheBuildCache // GoCacheLintCache represents the lint cache (e.g., golangci-lint). GoCacheLintCache )
func (GoCacheType) Count ¶
func (gt GoCacheType) Count() int
Count returns the number of enabled cache types.
func (GoCacheType) EnabledTypes ¶
func (gt GoCacheType) EnabledTypes() []GoCacheType
EnabledTypes returns a slice of all enabled cache types.
func (GoCacheType) Has ¶
func (gt GoCacheType) Has(cacheType GoCacheType) bool
Has checks if the given cache type is enabled.
func (GoCacheType) IsValid ¶
func (gt GoCacheType) IsValid() bool
IsValid checks if at least one cache type is enabled.
func (GoCacheType) String ¶
func (gt GoCacheType) String() string
String returns a human-readable string for the cache type.
type GoCleaner ¶
type GoCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
GoCleaner handles Go language cleanup using type-safe cache flags.
func NewGoCleaner ¶
func NewGoCleaner(verbose, dryRun bool, caches GoCacheType) (*GoCleaner, error)
NewGoCleaner creates Go cleaner with type-safe cache configuration.
func NewGoCleanerWithSettings ¶
func NewGoCleanerWithSettings(verbose, dryRun bool, caches GoCacheType) *GoCleaner
NewGoCleanerWithSettings creates Go cleaner with type-safe cache configuration (panics on invalid caches). This is a convenience function for tests and backward compatibility.
func (*GoCleaner) IsAvailable ¶
IsAvailable checks if Go is available.
func (*GoCleaner) Type ¶
func (gc *GoCleaner) Type() domain.OperationType
Type returns operation type.
func (*GoCleaner) ValidateSettings ¶
func (gc *GoCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates settings.
type GoScanner ¶
type GoScanner struct {
// contains filtered or unexported fields
}
GoScanner handles scanning for Go caches.
func NewGoScanner ¶
type GolangciLintCacheCleaner ¶
type GolangciLintCacheCleaner struct {
CleanerBase
}
GolangciLintCacheCleaner handles golangci-lint cache cleanup.
func NewGolangciLintCacheCleaner ¶
func NewGolangciLintCacheCleaner(verbose, dryRun bool) *GolangciLintCacheCleaner
NewGolangciLintCacheCleaner creates a new golangci-lint cache cleaner.
func (*GolangciLintCacheCleaner) Clean ¶
func (glcc *GolangciLintCacheCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean removes golangci-lint cache.
func (*GolangciLintCacheCleaner) IsAvailable ¶
func (glcc *GolangciLintCacheCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if golangci-lint is installed.
func (*GolangciLintCacheCleaner) Name ¶
func (glcc *GolangciLintCacheCleaner) Name() string
Name returns the cleaner name for result tracking.
func (*GolangciLintCacheCleaner) Type ¶
func (glcc *GolangciLintCacheCleaner) Type() domain.OperationType
Type returns operation type.
func (*GolangciLintCacheCleaner) ValidateSettings ¶
func (glcc *GolangciLintCacheCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates settings.
type HomebrewCleaner ¶
type HomebrewCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
HomebrewCleaner handles Homebrew package manager cleanup with proper type safety.
func NewHomebrewCleaner ¶
func NewHomebrewCleaner(verbose, dryRun bool, unusedOnly domain.HomebrewMode) *HomebrewCleaner
NewHomebrewCleaner creates Homebrew cleaner with proper configuration.
func (*HomebrewCleaner) Clean ¶
func (hbc *HomebrewCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean removes old Homebrew packages with proper type safety.
func (*HomebrewCleaner) IsAvailable ¶
func (hbc *HomebrewCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if Homebrew cleaner is available.
func (*HomebrewCleaner) Name ¶
func (hbc *HomebrewCleaner) Name() string
Name returns the unique identifier for this cleaner.
func (*HomebrewCleaner) Type ¶
func (hbc *HomebrewCleaner) Type() domain.OperationType
Type returns operation type for Homebrew cleaner.
func (*HomebrewCleaner) ValidateSettings ¶
func (hbc *HomebrewCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates Homebrew cleaner settings with type safety.
type ImpactEstimate ¶
type ImpactEstimate struct {
CurrentRepoSizeMB float64
EstimatedNewSizeMB float64
SpaceReclaimedMB float64
FilesToRemove int
EstimatedCommits int
EstimatedDuration time.Duration
}
ImpactEstimate contains impact estimates for a history rewrite.
type IsAvailableConstructor ¶
IsAvailableConstructor is a function type for creating cleaners in tests that need IsAvailable.
type IsAvailableTestCase ¶
type IsAvailableTestCase struct {
Name string
Constructor IsAvailableConstructor
}
IsAvailableTestCase represents a test case for IsAvailable tests.
type JVMBuildToolType ¶
type JVMBuildToolType string
JVMBuildToolType represents different JVM build tool types.
const ( JVMBuildToolGradle JVMBuildToolType = "gradle" JVMBuildToolMaven JVMBuildToolType = "maven" JVMBuildToolSBT JVMBuildToolType = "sbt" )
func AvailableBuildTools ¶
func AvailableBuildTools() []JVMBuildToolType
AvailableBuildTools returns all available JVM build tool types.
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector provides observability hooks for cleaner operations. It can be used to track performance, success rates, and other metrics.
func NewMetricsCollector ¶
func NewMetricsCollector() *MetricsCollector
NewMetricsCollector creates a new metrics collector.
func (*MetricsCollector) GetMetrics ¶
func (mc *MetricsCollector) GetMetrics(cleanerName string) (CleanerMetrics, bool)
GetMetrics returns metrics for a specific cleaner.
func (*MetricsCollector) RecordFailure ¶
func (mc *MetricsCollector) RecordFailure( cleanerName string, startTime time.Time, err error, )
RecordFailure records a failed cleaner operation.
func (*MetricsCollector) RecordStart ¶
func (mc *MetricsCollector) RecordStart(cleanerName string) time.Time
RecordStart records the start of a cleaner operation.
func (*MetricsCollector) RecordSuccess ¶
func (mc *MetricsCollector) RecordSuccess( cleanerName string, startTime time.Time, res domain.CleanResult, )
RecordSuccess records a successful cleaner operation.
func (*MetricsCollector) Snapshot ¶
func (mc *MetricsCollector) Snapshot() MetricsSnapshot
Snapshot returns a snapshot of all metrics.
type MetricsEnabledRegistry ¶
type MetricsEnabledRegistry struct {
*Registry
// contains filtered or unexported fields
}
MetricsEnabledRegistry extends Registry with metrics collection.
func NewMetricsEnabledRegistry ¶
func NewMetricsEnabledRegistry(registry *Registry) *MetricsEnabledRegistry
NewMetricsEnabledRegistry creates a new metrics-enabled registry.
func (*MetricsEnabledRegistry) CleanAllParallelWithMetrics ¶
func (r *MetricsEnabledRegistry) CleanAllParallelWithMetrics( ctx context.Context, maxConcurrency int, ) map[string]CleanResultWithMetrics
CleanAllParallelWithMetrics runs all cleaners in parallel with metrics.
func (*MetricsEnabledRegistry) CleanAllWithMetrics ¶
func (r *MetricsEnabledRegistry) CleanAllWithMetrics( ctx context.Context, ) map[string]result.Result[domain.CleanResult]
CleanAllWithMetrics runs all cleaners with metrics collection.
func (*MetricsEnabledRegistry) GetCollector ¶
func (r *MetricsEnabledRegistry) GetCollector() *MetricsCollector
GetCollector returns the metrics collector.
type MetricsSnapshot ¶
type MetricsSnapshot struct {
Cleaners map[string]CleanerMetrics
TotalCleaners int
TotalRuns uint64
TotalSuccesses uint64
TotalFailures uint64
TotalBytesFreed uint64
}
MetricsSnapshot provides a point-in-time view of all metrics.
type NixCleaner ¶
type NixCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
NixCleaner handles Nix package manager cleanup with proper type safety.
func NewNixCleaner ¶
func NewNixCleaner(verbose, dryRun bool, keepCount ...int) *NixCleaner
NewNixCleaner creates Nix cleaner with proper configuration.
func (*NixCleaner) Clean ¶
func (nc *NixCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean implements the Cleaner interface. It removes old Nix generations, keeping the configured number of generations.
func (*NixCleaner) CleanOldGenerations ¶
func (nc *NixCleaner) CleanOldGenerations( ctx context.Context, keepCount int, ) result.Result[domain.CleanResult]
CleanOldGenerations removes old Nix generations using centralized conversions.
func (*NixCleaner) GetStoreSize ¶
func (nc *NixCleaner) GetStoreSize(ctx context.Context) int64
GetStoreSize gets Nix store size with type safety.
func (*NixCleaner) IsAvailable ¶
func (nc *NixCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if Nix cleaner is available.
func (*NixCleaner) ListGenerations ¶
func (nc *NixCleaner) ListGenerations(ctx context.Context) result.Result[[]domain.NixGeneration]
ListGenerations lists Nix generations with proper type safety.
func (*NixCleaner) Name ¶
func (nc *NixCleaner) Name() string
Name returns the unique identifier for this cleaner.
func (*NixCleaner) Type ¶
func (nc *NixCleaner) Type() domain.OperationType
Type returns the operation type for Nix cleaner.
func (*NixCleaner) ValidateSettings ¶
func (nc *NixCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates Nix cleaner settings with type safety.
type NixStoreSizer ¶
type NixStoreSizer interface {
// GetStoreSize returns the size of the Nix store in bytes.
// Returns 0 if Nix is not available.
GetStoreSize(ctx context.Context) int64
}
NixStoreSizer defines the interface for cleaners that can report store size.
type NodePackageManagerCleaner ¶
type NodePackageManagerCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
NodePackageManagerCleaner handles Node.js package manager cleanup.
func NewNodePackageManagerCleaner ¶
func NewNodePackageManagerCleaner( verbose, dryRun bool, packageManagers []domain.PackageManagerType, ) *NodePackageManagerCleaner
NewNodePackageManagerCleaner creates Node.js package manager cleaner.
func (*NodePackageManagerCleaner) Clean ¶
func (npmc *NodePackageManagerCleaner) Clean( ctx context.Context, ) result.Result[domain.CleanResult]
Clean removes Node.js package manager caches.
func (*NodePackageManagerCleaner) IsAvailable ¶
func (npmc *NodePackageManagerCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if any Node.js package manager is available.
func (*NodePackageManagerCleaner) Name ¶
func (npmc *NodePackageManagerCleaner) Name() string
Name returns the cleaner name for result tracking.
func (*NodePackageManagerCleaner) Type ¶
func (npmc *NodePackageManagerCleaner) Type() domain.OperationType
Type returns operation type for Node package manager cleaner.
func (*NodePackageManagerCleaner) ValidateSettings ¶
func (npmc *NodePackageManagerCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates Node package manager cleaner settings.
type ParallelExecutor ¶
type ParallelExecutor struct {
// contains filtered or unexported fields
}
ParallelExecutor executes cleaners in parallel with configurable concurrency.
func NewParallelExecutor ¶
func NewParallelExecutor(maxConcurrency int) *ParallelExecutor
NewParallelExecutor creates a new parallel executor with the specified max concurrency. If maxConcurrency <= 0, it defaults to the number of available cleaners.
func (*ParallelExecutor) Execute ¶
func (pe *ParallelExecutor) Execute( ctx context.Context, cleaners []Cleaner, ) []CleanResultWithMetrics
Execute runs the given cleaners in parallel and returns results with metrics. The context can be used to cancel all ongoing operations.
func (*ParallelExecutor) GetMaxConcurrency ¶
func (pe *ParallelExecutor) GetMaxConcurrency() int
GetMaxConcurrency returns the current maximum concurrency level.
func (*ParallelExecutor) SetMaxConcurrency ¶
func (pe *ParallelExecutor) SetMaxConcurrency(maxConcurrency int)
SetMaxConcurrency updates the maximum concurrency level.
type ProjectExecutablesCleaner ¶
type ProjectExecutablesCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
ProjectExecutablesCleaner removes executable files (not shell scripts) from project directories. It integrates with projects-management-automation to discover projects and uses trash for safe deletion.
func NewProjectExecutablesCleaner ¶
func NewProjectExecutablesCleaner( verbose, dryRun bool, excludeExtensions, excludePatterns []string, opts ...ProjectExecutablesOption, ) *ProjectExecutablesCleaner
NewProjectExecutablesCleaner creates a new ProjectExecutablesCleaner.
func (*ProjectExecutablesCleaner) Clean ¶
func (p *ProjectExecutablesCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean removes executable files from project directories using trash.
func (*ProjectExecutablesCleaner) GetStoreSize ¶
func (p *ProjectExecutablesCleaner) GetStoreSize(ctx context.Context) int64
GetStoreSize returns the total size of all executable files found.
func (*ProjectExecutablesCleaner) IsAvailable ¶
func (p *ProjectExecutablesCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if projects-management-automation and trash are available.
func (*ProjectExecutablesCleaner) IsExcludedByExtension ¶
func (p *ProjectExecutablesCleaner) IsExcludedByExtension(filename string) bool
IsExcludedByExtension checks if the file should be excluded based on its extension.
func (*ProjectExecutablesCleaner) IsExcludedByPattern ¶
func (p *ProjectExecutablesCleaner) IsExcludedByPattern(filename string) bool
IsExcludedByPattern checks if the file should be excluded based on glob patterns.
func (*ProjectExecutablesCleaner) Name ¶
func (p *ProjectExecutablesCleaner) Name() string
Name returns the cleaner name for result tracking.
func (*ProjectExecutablesCleaner) Type ¶
func (p *ProjectExecutablesCleaner) Type() domain.OperationType
Type returns operation type for Project Executables cleaner.
func (*ProjectExecutablesCleaner) ValidateSettings ¶
func (p *ProjectExecutablesCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates Project Executables cleaner settings.
type ProjectExecutablesOption ¶
type ProjectExecutablesOption func(*ProjectExecutablesCleaner)
ProjectExecutablesOption is a functional option for configuring the cleaner.
func WithFileOperator ¶
func WithFileOperator(operator FileOperator) ProjectExecutablesOption
WithFileOperator sets a custom file operator for testing.
func WithProjectLister ¶
func WithProjectLister(lister ProjectLister) ProjectExecutablesOption
WithProjectLister sets a custom project lister for testing.
type ProjectInfo ¶
type ProjectInfo struct {
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"`
Status string `json:"status"`
}
ProjectInfo represents a project from projects-management-automation list.
type ProjectLister ¶
type ProjectLister interface {
ListProjects(ctx context.Context) ([]ProjectInfo, error)
}
ProjectLister defines the interface for listing projects. This interface enables mocking in tests.
type ProjectsManagementAutomationCleaner
deprecated
type ProjectsManagementAutomationCleaner struct {
CleanerBase
}
ProjectsManagementAutomationCleaner handles projects-management-automation cache cleanup.
Deprecated: This cleaner requires the external 'projects-management-automation' tool which is not commonly available. It will be removed in a future version. Use ProjectExecutablesCleaner or CompiledBinariesCleaner instead.
func NewProjectsManagementAutomationCleaner ¶
func NewProjectsManagementAutomationCleaner( verbose, dryRun bool, ) *ProjectsManagementAutomationCleaner
NewProjectsManagementAutomationCleaner creates Projects Management Automation cleaner.
func (*ProjectsManagementAutomationCleaner) Clean ¶
func (pc *ProjectsManagementAutomationCleaner) Clean( ctx context.Context, ) result.Result[domain.CleanResult]
Clean removes Projects Management Automation cache.
func (*ProjectsManagementAutomationCleaner) IsAvailable ¶
func (pc *ProjectsManagementAutomationCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if projects-management-automation is available.
func (*ProjectsManagementAutomationCleaner) Name ¶
func (pc *ProjectsManagementAutomationCleaner) Name() string
Name returns the cleaner name for result tracking.
func (*ProjectsManagementAutomationCleaner) Scan ¶
func (pc *ProjectsManagementAutomationCleaner) Scan( ctx context.Context, ) result.Result[[]domain.ScanItem]
Scan scans for Projects Management Automation cache.
func (*ProjectsManagementAutomationCleaner) Type ¶
func (pc *ProjectsManagementAutomationCleaner) Type() domain.OperationType
Type returns operation type for Projects Management Automation cleaner.
func (*ProjectsManagementAutomationCleaner) ValidateSettings ¶
func (pc *ProjectsManagementAutomationCleaner) ValidateSettings( settings *domain.OperationSettings, ) error
ValidateSettings validates Projects Management Automation cleaner settings.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages all registered cleaners. It provides thread-safe access to cleaner instances and enables polymorphic operations over all cleaners.
func DefaultRegistry ¶
DefaultRegistry creates a new registry with all cleaners registered. Cleaners are created with default settings (verbose=false, dryRun=false). This is useful for availability checks and discovery. Returns an error if any cleaner fails to initialize.
func DefaultRegistryWithConfig ¶
DefaultRegistryWithConfig creates a registry with cleaners configured for actual cleaning. This should be used when performing clean operations. Returns an error if any cleaner fails to initialize.
func (*Registry) Available ¶
Available returns all cleaners that are available on the current system.
func (*Registry) CleanAll ¶
CleanAll runs all available cleaners and aggregates results. Returns a map of cleaner name to result.
func (*Registry) CleanAllParallel ¶
func (r *Registry) CleanAllParallel( ctx context.Context, maxConcurrency int, ) map[string]CleanResultWithMetrics
CleanAllParallel runs all available cleaners in parallel with configurable concurrency. This is a convenience method on Registry.
func (*Registry) Get ¶
Get retrieves a cleaner by name. Returns the cleaner and true if found, nil and false otherwise.
func (*Registry) List ¶
List returns all registered cleaners. The order of cleaners in the returned slice is not guaranteed.
func (*Registry) Register ¶
Register adds a cleaner to the registry. If a cleaner with the same name already exists, it will be overwritten.
func (*Registry) Unregister ¶
Unregister removes a cleaner from the registry.
type RemoveFunc ¶
type ScanDirectoryResult ¶
ScanDirectoryResult represents the result of scanning a directory.
func ScanDirectory ¶
func ScanDirectory(path string, scanType domain.ScanType, verbose bool) ScanDirectoryResult
ScanDirectory scans a directory and returns scan items if it exists and is a directory. This helper consolidates the common pattern of checking if a path exists and is a directory, then creating scan items for it.
func ScanPath ¶
func ScanPath( homeDir string, scanType domain.ScanType, displayName string, verbose bool, pattern string, pathComponents ...string, ) ScanDirectoryResult
ScanPath scans a directory path constructed from components and returns scan items. This is a generic helper that consolidates the common pattern of: 1. Constructing a path from components (homeDir + pathComponents) 2. Checking if the path exists and is a directory 3. Creating a scan item for the directory If homeDir is empty and pathComponents contains a complete path, it uses that directly. If pattern is provided, it walks the directory to find matching entries instead of scanning.
type ScanItemFunc ¶
type ScanItemFunc[T any] func(ctx context.Context, item T, homeDir string) result.Result[[]domain.ScanItem]
ScanItemFunc is a function that scans for items of type T and returns scan results.
type SimpleCleaner ¶
type SimpleCleaner interface {
IsAvailable(ctx context.Context) bool
Clean(ctx context.Context) result.Result[domain.CleanResult]
}
SimpleCleaner represents a cleaner interface without settings validation.
type SimpleCleanerConstructor ¶
type SimpleCleanerConstructor func(verbose, dryRun bool) SimpleCleaner
SimpleCleanerConstructor is a function type for creating cleaners in tests that only need Clean and IsAvailable.
func SimpleCleanerConstructorFromInstance ¶
func SimpleCleanerConstructorFromInstance[T SimpleCleaner](cleaner T) SimpleCleanerConstructor
SimpleCleanerConstructorFromInstance creates a SimpleCleanerConstructor from an existing cleaner instance.
func ToSimpleCleanerConstructor ¶
func ToSimpleCleanerConstructor( fullConstructor CleanerConstructorWithSettings, ) SimpleCleanerConstructor
ToSimpleCleanerConstructor converts a constructor with additional methods to one that only exposes Clean and IsAvailable.
type SizeEstimatorFunc ¶
SizeEstimatorFunc is a function that estimates the size of an item for dry-run mode.
type SystemCacheCleaner ¶
type SystemCacheCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
SystemCacheCleaner handles system cache cleanup for macOS and Linux.
func NewSystemCacheCleaner ¶
func NewSystemCacheCleaner( verbose, dryRun bool, olderThan string, cacheTypes []domain.CacheType, ) (*SystemCacheCleaner, error)
NewSystemCacheCleaner creates system cache cleaner.
func (*SystemCacheCleaner) Clean ¶
func (scc *SystemCacheCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean removes system caches.
func (*SystemCacheCleaner) IsAvailable ¶
func (scc *SystemCacheCleaner) IsAvailable(_ context.Context) bool
IsAvailable checks if system cache cleaner is available.
func (*SystemCacheCleaner) Name ¶
func (scc *SystemCacheCleaner) Name() string
Name returns the cleaner name for result tracking.
func (*SystemCacheCleaner) Type ¶
func (scc *SystemCacheCleaner) Type() domain.OperationType
Type returns operation type for system cache cleaner.
func (*SystemCacheCleaner) ValidateSettings ¶
func (scc *SystemCacheCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates system cache cleaner settings.
type TempFilesCleaner ¶
type TempFilesCleaner struct {
CleanerBase
// contains filtered or unexported fields
}
TempFilesCleaner handles temporary files cleanup with proper type safety.
func NewTempFilesCleaner ¶
func NewTempFilesCleaner( verbose, dryRun bool, olderThan string, excludes, basePaths []string, ) (*TempFilesCleaner, error)
NewTempFilesCleaner creates temp files cleaner with proper configuration.
func (*TempFilesCleaner) Clean ¶
func (tfc *TempFilesCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean removes old temp files with proper type safety.
func (*TempFilesCleaner) IsAvailable ¶
func (tfc *TempFilesCleaner) IsAvailable(ctx context.Context) bool
IsAvailable checks if temp files cleaner is available.
func (*TempFilesCleaner) Name ¶
func (tfc *TempFilesCleaner) Name() string
Name returns the cleaner name for result tracking.
func (*TempFilesCleaner) Type ¶
func (tfc *TempFilesCleaner) Type() domain.OperationType
Type returns operation type for temp files cleaner.
func (*TempFilesCleaner) ValidateSettings ¶
func (tfc *TempFilesCleaner) ValidateSettings(settings *domain.OperationSettings) error
ValidateSettings validates temp files cleaner settings with type safety.
type TrackedCleaner ¶
type TrackedCleaner struct {
Cleaner
// contains filtered or unexported fields
}
TrackedCleaner wraps a cleaner with metrics collection.
func NewTrackedCleaner ¶
func NewTrackedCleaner(c Cleaner, collector *MetricsCollector) *TrackedCleaner
NewTrackedCleaner creates a new tracked cleaner wrapper.
func (*TrackedCleaner) Clean ¶
func (tc *TrackedCleaner) Clean(ctx context.Context) result.Result[domain.CleanResult]
Clean executes the cleaner and records metrics.
type ValidateSettingsTestCase ¶
type ValidateSettingsTestCase struct {
Name string
Settings *domain.OperationSettings
WantErr bool
}
ValidateSettingsTestCase represents a test case for ValidateSettings.
func CreateBooleanSettingsTestCases ¶
func CreateBooleanSettingsTestCases( nilName string, settingsFunc func(bool) *domain.OperationSettings, ) []ValidateSettingsTestCase
CreateBooleanSettingsTestCases creates standard test cases for cleaners with a single boolean settings field. This eliminates duplicate test case code across multiple cleaner test files.
Parameters:
- nilName: Name describing the settings field (e.g., "cargo packages" for Cargo)
- settingsFunc: Function that creates an OperationSettings with the specific field configured
Returns test cases for:
- nil settings (valid)
- empty OperationSettings (valid)
- settings with field enabled (valid)
- settings with field disabled (valid)
Source Files
¶
- buildcache.go
- cargo.go
- cleaner.go
- compiledbinaries.go
- docker.go
- docker_parsing.go
- fsutil.go
- ginkgo_test_helpers.go
- githistory.go
- githistory_executor.go
- githistory_filterrepo.go
- githistory_safety.go
- githistory_scanner.go
- golang_cache_cleaner.go
- golang_cleaner.go
- golang_helpers.go
- golang_scanner.go
- golang_types.go
- golangcilint.go
- helpers.go
- homebrew.go
- metrics.go
- nix.go
- nodepackages.go
- parallel.go
- projectexecutables.go
- projectsmanagementautomation.go
- registry.go
- registry_factory.go
- systemcache.go
- tempfiles.go
- test_assertions.go
- test_factories.go
- test_helpers.go
- test_interfaces.go
- testing_helpers.go
- validate.go