Help us shape the future of Go! Take the 2026 Go Developer Survey

cleanup

package
v1.56.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MultiSelectPrompt = func(string, []string, []string) ([]string, error) {
	return nil, fmt.Errorf("MultiSelectPrompt not wired: command layer must assign it")
}

MultiSelectPrompt asks the user to pick cleanup operations. Wired by the command layer (cmd/compose and cmd/clean inits) so this package never imports presentation code for prompting; tests override it per-case. Defaults fail loudly instead of hanging on stdin.

Functions

func GetDockerDiskUsage

func GetDockerDiskUsage() (string, error)

GetDockerDiskUsage returns the raw output of docker system df.

func IsDockerAvailable

func IsDockerAvailable() bool

IsDockerAvailable checks if the docker CLI is present and the daemon responds.

func ParseReclaimedBytes

func ParseReclaimedBytes(output string) int64

ParseReclaimedBytes extracts the byte count from docker prune output.

Types

type CleanupTask

type CleanupTask struct {
	ID          string
	Label       string
	Category    string
	Execute     func(opts SystemCleanOptions) (int64, string, error)
	IsAvailable func() bool
}

CleanupTask represents a discrete maintenance task.

type DockerCleanOptions

type DockerCleanOptions struct {
	All        bool
	OlderThan  string
	BuildCache bool
	Volumes    bool
	DryRun     bool
	Verbose    bool
}

DockerCleanOptions holds configuration options for Docker cleanup.

type ItemResult

type ItemResult struct {
	Name        string `json:"name"`
	Category    string `json:"category"`
	Status      Status `json:"status"`
	FreedBytes  int64  `json:"freed_bytes"`
	Message     string `json:"message,omitempty"`
	ReclaimText string `json:"reclaim_text,omitempty"`
}

ItemResult records the outcome of a single cleanup operation.

type Report

type Report struct {
	Items           []ItemResult `json:"items"`
	TotalFreedBytes int64        `json:"total_freed_bytes"`
}

Report aggregates multiple cleanup results and renders summary metrics.

func RunDockerCleanup

func RunDockerCleanup(opts DockerCleanOptions) (*Report, error)

RunDockerCleanup performs granular Docker engine pruning.

func RunSystemCleanup

func RunSystemCleanup(opts SystemCleanOptions) (*Report, error)

RunSystemCleanup orchestrates full host maintenance across OS types.

func (*Report) Add

func (r *Report) Add(item ItemResult)

Add appends an item result to the report and updates running totals.

func (*Report) RenderSummaryTable

func (r *Report) RenderSummaryTable() string

RenderSummaryTable formats a terminal summary card for all cleanup results.

type Status

type Status string

Status represents the completion state of a cleanup item.

const (
	StatusSuccess Status = "Success"
	StatusSkipped Status = "Skipped"
	StatusFailed  Status = "Failed"
)

type SystemCleanOptions

type SystemCleanOptions struct {
	Docker         bool
	DockerOpts     DockerCleanOptions
	Journal        bool
	JournalSize    string
	Packages       bool
	Asdf           bool
	Brew           bool
	DryRun         bool
	Verbose        bool
	AutoApprove    bool
	CleanupTimeout int
}

SystemCleanOptions holds configuration options for full host cleanup.

Jump to

Keyboard shortcuts

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