$ show gdraheim/docker-copyedit
docker-copyedit is a CLI tool for editing Docker image metadata, including removing/adding volumes, ports, environment variables, labels, and modifying image configuration like user, workdir, entrypoint, and cmd. The tool works by saving a Docker image to a tarball, extracting and modifying the metadata JSON files (manifest.json and config files), then re-packaging and loading the modified image. It supports both Docker and Podman via command-line flags. The architecture is a monolithic Python application with a clear separation between the CLI wrapper and core implementation. Key functions include parsing Docker image names, executing shell commands with proper error handling, and a custom command-line DSL for specifying image modifications.
The LLM identified 3 files worth highlighting for reuse:
The ImageName class provides robust parsing and validation of Docker image names, handling registries, ports, versions, and digests according to Docker's naming specifications. It's a self-contained component that could be extracted for use in any Docker-related tool needing to manipulate image references.
The ShellResult namedtuple and ShellException class provide a clean wrapper around subprocess.Popen with consistent error handling, logging, and dry-run support. This pattern eliminates boilerplate subprocess code and ensures uniform command execution throughout the application.
The parse_commands function implements a domain-specific language for Docker image editing commands, supporting complex syntax like 'FROM image1 INTO image2 REMOVE ALL VOLUMES' with proper validation and error handling. This custom parser demonstrates skill in creating flexible, user-friendly command interfaces.