Skip to content

Feature: Exclusion Patterns (--exclude) for Safe Cleanup #4

@tejaswankalluri

Description

@tejaswankalluri

Problem:
The current cleanup logic is broad (based on age or type). Users often have specific "pet" resources (e.g., a stopped postgres container with development data, or a base image) that they never want to delete, even if it falls within the cleanup criteria. Currently, they have to clean manually or risk losing these resources.

Proposed Solution:
Add an --exclude <pattern> flag that allows users to specify patterns for resources to be ignored during the scan and clean process.

Requirements:

  1. Multiple Exclusions: Support multiple flags in one command.
    • Example: docklean --all --exclude "prod-*" --exclude "my-local-db"
  2. Pattern Matching: Support standard glob patterns (e.g., *, ?) or regex for flexible matching against resource names/IDs.
  3. Scope: The exclusion should apply to all resource types being scanned (Containers, Images, Volumes, Networks).

Expected Outcome:

  • Resources matching the provided patterns are completely omitted from the scan results.
  • These resources are never removed, regardless of their age or status.
  • The summary output should ideally (optional but nice) mention that some items were excluded by user request.

Implementation Hints:

  • Update src/args.ts to parse --exclude as a string array.
  • Update src/scan.ts to filter items immediately after fetching from Docker, before applying age filters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions