Repository navigation
Open
Description
This tracking issue collects the follow-ups from a design review of the CLI at ed268992. It assumes the oras-go v3 migration (#2008 / #2002) lands, and items are adjusted to that. The four concrete bugs from the review are filed separately: #2276, #2277, #2278, #2279.
Each item can be split into its own issue or PR when someone picks it up. File references are against main.
Command & option layer
- Extract copy plumbing from
cp.go(849 lines). The defaultCopyGraphOptions+concurrency+PreCopy/PostCopy/OnCopySkippedblock is repeated inpush.go:266,attach.go:199,backup.go:225,restore.go:191andcp.go:589-635.recursiveCopy/prepareCopyOption(cp.go:684-827, reused by backup/restore) and the platform/index filters (cp.go:391-587) are pure logic that lives in a cobra file. Move them tointernal/copyutil(orinternal/graph), addstatus.Handler.ApplyTo(*oras.CopyGraphOptions), and drop the unused_ oras.Targetparameter onprepareCopyOption. - Have backup/restore use
option.Target. Both embed a bareoption.Remoteand parse references by hand (backup.go:402). Restore re-implements "open a dir or tar as OCI layout" (restore.go:146-173), which duplicatesTarget.NewReadonlyTarget. cp (cp.go:118) and push (push.go:127) each split tags on,themselves. Introduce one sharedoption.TaggedReferenceparser. - Simplify the Target/Remote layering.
- There are two prefix sources of truth (
Target.prefixvsRemote.flagPrefix,target.go:63,100). - The same type switch is repeated in
NewTarget/NewBlobDeleter/NewManifestDeleter/NewReadonlyTarget(target.go:166-232). remo.storeis only set as a side effect ofauthClient(remote.go:460), soConfigPath()depends on call order.Target.ModifyErrorshort-circuits onIsOCILayoutrather thanType == TargetTypeOCILayout(target.go:244).- v3: replace the hand-rolled TLS,
--resolve, header and credential-transport assembly inremote.gowithremote.ClientBuilder+properties.Registry, alongside feat: load containers config stack (auth.json, certs.d, registries.conf) behind an experimental env var #2273.
- There are two prefix sources of truth (
- Extract a shared packer for push and attach. Config-file loading is duplicated (
push.go:198-208,attach.go:206-217),doPush/pushArtifactare thin wrappers around a dead parameter, and validation is inline inPreRunE(push.go:138-166). Extract the packing and add a unit-testableValidate(). - Use a parse → validate → run structure with injected I/O.
- Use
cmd.InOrStdin()instead ofos.Stdin(remote.go:213,login.go:128,136,blob/delete.go:103,manifest/delete.go:112). readSecretchecks the unprefixed flag names (remote.go:207-209), so the insecure-password warning never fires for--from-password/--to-password.- Add unit tests for
runCopy, attach, backup and restore.restore_test.go,root/repoandroot/manifest/commonhave none today.
- Use
- Make flags consistent.
--concurrencydefaults to 3 (cp, pull, backup) or 5 (push, attach, restore, tag, manifest push), with no>= 1validation. Use oneoption.Concurrency.- backup has
--include-referrerswhile restore has--exclude-referrers. --configmeans "file to upload" in push/attach but "where to write" in pull.pullOptionsexports its fields.
- Wire the deprecated
--verboseflag in one place.option.AddDeprecatedVerboseFlagexists, yet cp, push, attach, pull, discover, manifest push and blob push wire their own default-trueverboseby hand. Use anoption.DeprecatedVerboseapplier/parser, and pick a removal version. - Turn Experimental/Preview gating into annotations. About 20 help strings carry hand-written
[Experimental]/[Preview]prefixes. Addoption.MarkExperimental(fs, name)plus a lint test and a generated list of stability levels. - Document the embedded-struct order. The reflection-based
Parse/ApplyFlagsrelies on embedded-field declaration order (parser.go:43-56). Document it or make it explicit.
Display layer
- Merge the duplicated status handlers. Push/Copy/Backup/Restore repeat one algorithm 4× in
status/text.goand 4× instatus/tty.go, with only the prompt strings differing. Use a single text and a single TTY "copy status" handler configured with a prompt set (about −400 lines). The copies have already drifted: TTY copy usesch.trackedas its fetcher (tty.go:213). - Use one tracking lifecycle.
TrackTarget()(push/attach/pull) vsStartTracking/StopTracking(copy/backup/restore/blob push). Use oneTrackerinterface, then collapseBackupHandler/RestoreHandler/CopyHandler(interface.go:69-85are identical). - Remove the no-op boilerplate.
DiscardHandlerhas 23 no-op methods. Embed anoopbase and split the interfaces by responsibility. - Merge the
json/andtemplate/metadata handlers. Each pair differs only by the encoder call. Use handlers that takeencode func(io.Writer, any) error, which halves the files and makes a new format such as yaml one line. - Send status to stderr (breaking change). Text status currently goes to stdout, so
--format jsonswaps inDiscardHandler(handler.go:44-48,69-73,94-98) and users lose progress output. A separate status writer on stderr would make status independent of--format. Candidate for the next major version. - Make
--formatand--descriptoroutput consistent.--descriptorwrites to a hard-codedos.Stdout(blob push/fetch/delete, manifest push/delete), which bypasses the display layer and test capture. It is also why a dead_ boolpretty parameter exists (handler.go:173,250). Route it through a descriptor metadata handler.- Only 7 commands accept
--format. - The model constructors return
any. Return named types and add golden-file JSON schema tests. repo tagsomitsregistrywhilerepo lsincludes it.json/pull.gobuildspath@digestby hand instead ofmodel.NewDigestReference.
- Fix the small display API issues.
Printer.Printfswallows errors whilePrintlnreturns them.- TTY handlers dereference
trackedbefore tracking starts (tty.go:79). OnAttachedreturns no error, unlike the other handlers.- Handler factories take
*os.File. Passio.Writer+isTTYinstead so they can be table-tested.
Errors, signals, logging
- Decorate errors centrally.
ModifyErroris opt-in per command (21 files), andlogout,versionandPreRunE/Argserrors skip it.Remote.ModifyErrorandTarget.ModifyErrorduplicate branches (remote.go:579,target.go:243).TrimErrBasicCredentialNotFound/reWrap(errors.go:134-172) rebuild errors by matching message substrings. v3: match oras-go v3's typed errors witherrors.Is/Asinstead. - Exit codes and signals. Everything exits 1 (
main.go:28-35). Map usage → 2, canceled → 130, and so on through aCodefield onoerrors.Error. Handle SIGTERM, and callstop()after the first signal so a second Ctrl-C force-quits. - v3 logging: adopt
ClientBuilder.Logger(slog) and dropinternal/traceand logrus. Today the--debugtrace transport wraps the retry transport (remote.go:411vs:450), so retried attempts are invisible. Note that oras-go v3'sClientBuilder.buildTransportalso places the logging transport outsideretry.Transportwhile its comment says "each attempt is individually logged". That needs fixing upstream before the CLI relies on it.
Move code upstream into oras-go v3 / delete it
- Replace
internal/cachewith v3's publiccontent/cache. - Replace
internal/credential(multi-config fallback store) with the v3 config stack (feat: load containers config stack (auth.json, certs.d, registries.conf) behind an experimental env var #2273). - Move to oras-go, or use v3 equivalents for:
internal/contentutil.MultiReadOnlyTarget,registryutil.WithScopeHint, the exported Docker media types, andinternal/graphsuccessors beyondcontent.Successors. -
internal/contentutil/traverse.goTraversingTargetworks around copyGraph skipping a sub-DAG when its root exists. Propose aCopyGraphOptionssetting upstream. - Delete
internal/mock, which has no importers.
Build & test
-
make testdepends ontidy vendor(Makefile:55) and rewritesgo.modandvendor/on every run. Drop those prerequisites and add atidy-checktarget. - Replace the 13 copy-pasted
build-*targets (Makefile:76-135) with oneGOOS/GOARCHpattern rule. - Pin ginkgo in
test/e2e/Dockerfile:49(currently@latest) to the version intest/e2e/go.mod. - Add a fast local e2e path (
docker rundistribution + zot,ginkgo -p, prebuilt binary throughORAS_PATH) and keep Kubernetes for nightly runs. - Add unit tests for
internal/registryutil(WithScopeHint), which has none.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
TerryHowe commentedon Oct 23, 2026
The upstream logging-order bug noted under Errors, signals, logging is filed as oras-project/oras-go#1680.