This file provides guidance to AI agents when working with code in this repository.
This is the oc-mirror repository - an OpenShift client tool for mirroring container registry content for disconnected cluster installs.
oc-mirror reads an ImageSetConfiguration YAML file and mirrors container images from source registries to:
- a target mirror registry (direct mirroring)
- a local cache on disk, then generates a tarball for later mirroring (air-gapped scenarios)
- mirrorToMirror (m2m) : direct registry-to-registry copying
- mirrorToDisk (m2d) : copy images to local cache and create tarball
- diskToMirror (d2m) : copy images from tarball to target registry
- v2 (Current) : code lives in the root directory - THIS IS WHAT YOU SHOULD WORK ON
- v1 (Deprecated) : code lives under the v1/ folder - DO NOT MODIFY v1 CODE
The oc-mirror project relies heavily on the container-libs library for low-level container image operations.
For each container image type, oc-mirror defines a Collector interface responsible for discovering all the related images:
| Collector | Location | Purpose |
|---|---|---|
| Release | internal/pkg/release |
Openshift release payloads |
| Operator | internal/pkg/operator |
RedHat operator catalogs |
| Helm | internal/pkg/helm |
Helm charts |
| Additional | internal/pkg/additional |
generic container images |
The image copying itself happens concurrently in batches via internal/pkg/batch for optimal performance.
The ImageSetConfiguration is defined in internal/pkg/api/v2alpha1/. See docs/image-set-examples/imaget-set-config.yaml for examples.
make clean # clean up build artifacts
make build # compiles the oc-mirror binaryImportant: always use make build, not go build directly - the Makefile sets required build tags.
make test-unit # run unit tests
make test-integration # run integration testsmake verify # run golangci-lint
make sanity # runs: tidy, format, and vet checks- Write understandable code. Always prefer clarity over other things.
- Write comments and documentation in English.
- Write unit tests for your code.
- When instructed to fix tests, do not remove or modify existing tests.
- Write documentation for your code.
- Run
make sanitybefore committing files.