Skip to content

Tracking: CLI design review follow-ups #2280

Open

Description

@TerryHowe

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 default CopyGraphOptions + concurrency + PreCopy/PostCopy/OnCopySkipped block is repeated in push.go:266, attach.go:199, backup.go:225, restore.go:191 and cp.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 to internal/copyutil (or internal/graph), add status.Handler.ApplyTo(*oras.CopyGraphOptions), and drop the unused _ oras.Target parameter on prepareCopyOption.
  • Have backup/restore use option.Target. Both embed a bare option.Remote and parse references by hand (backup.go:402). Restore re-implements "open a dir or tar as OCI layout" (restore.go:146-173), which duplicates Target.NewReadonlyTarget. cp (cp.go:118) and push (push.go:127) each split tags on , themselves. Introduce one shared option.TaggedReference parser.
  • Simplify the Target/Remote layering.
    • There are two prefix sources of truth (Target.prefix vs Remote.flagPrefix, target.go:63,100).
    • The same type switch is repeated in NewTarget/NewBlobDeleter/NewManifestDeleter/NewReadonlyTarget (target.go:166-232).
    • remo.store is only set as a side effect of authClient (remote.go:460), so ConfigPath() depends on call order.
    • Target.ModifyError short-circuits on IsOCILayout rather than Type == TargetTypeOCILayout (target.go:244).
    • v3: replace the hand-rolled TLS, --resolve, header and credential-transport assembly in remote.go with remote.ClientBuilder + properties.Registry, alongside feat: load containers config stack (auth.json, certs.d, registries.conf) behind an experimental env var #2273.
  • Extract a shared packer for push and attach. Config-file loading is duplicated (push.go:198-208, attach.go:206-217), doPush/pushArtifact are thin wrappers around a dead parameter, and validation is inline in PreRunE (push.go:138-166). Extract the packing and add a unit-testable Validate().
  • Use a parse → validate → run structure with injected I/O.
    • Use cmd.InOrStdin() instead of os.Stdin (remote.go:213, login.go:128,136, blob/delete.go:103, manifest/delete.go:112).
    • readSecret checks 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/repo and root/manifest/common have none today.
  • Make flags consistent.
    • --concurrency defaults to 3 (cp, pull, backup) or 5 (push, attach, restore, tag, manifest push), with no >= 1 validation. Use one option.Concurrency.
    • backup has --include-referrers while restore has --exclude-referrers.
    • --config means "file to upload" in push/attach but "where to write" in pull.
    • pullOptions exports its fields.
  • Wire the deprecated --verbose flag in one place. option.AddDeprecatedVerboseFlag exists, yet cp, push, attach, pull, discover, manifest push and blob push wire their own default-true verbose by hand. Use an option.DeprecatedVerbose applier/parser, and pick a removal version.
  • Turn Experimental/Preview gating into annotations. About 20 help strings carry hand-written [Experimental]/[Preview] prefixes. Add option.MarkExperimental(fs, name) plus a lint test and a generated list of stability levels.
  • Document the embedded-struct order. The reflection-based Parse/ApplyFlags relies 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.go and 4× in status/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 uses ch.tracked as its fetcher (tty.go:213).
  • Use one tracking lifecycle. TrackTarget() (push/attach/pull) vs StartTracking/StopTracking (copy/backup/restore/blob push). Use one Tracker interface, then collapse BackupHandler/RestoreHandler/CopyHandler (interface.go:69-85 are identical).
  • Remove the no-op boilerplate. DiscardHandler has 23 no-op methods. Embed a noop base and split the interfaces by responsibility.
  • Merge the json/ and template/ metadata handlers. Each pair differs only by the encoder call. Use handlers that take encode 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 json swaps in DiscardHandler (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 --format and --descriptor output consistent.
    • --descriptor writes to a hard-coded os.Stdout (blob push/fetch/delete, manifest push/delete), which bypasses the display layer and test capture. It is also why a dead _ bool pretty 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 tags omits registry while repo ls includes it.
    • json/pull.go builds path@digest by hand instead of model.NewDigestReference.
  • Fix the small display API issues.
    • Printer.Printf swallows errors while Println returns them.
    • TTY handlers dereference tracked before tracking starts (tty.go:79).
    • OnAttached returns no error, unlike the other handlers.
    • Handler factories take *os.File. Pass io.Writer + isTTY instead so they can be table-tested.

Errors, signals, logging

  • Decorate errors centrally. ModifyError is opt-in per command (21 files), and logout, version and PreRunE/Args errors skip it. Remote.ModifyError and Target.ModifyError duplicate 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 with errors.Is/As instead.
  • Exit codes and signals. Everything exits 1 (main.go:28-35). Map usage → 2, canceled → 130, and so on through a Code field on oerrors.Error. Handle SIGTERM, and call stop() after the first signal so a second Ctrl-C force-quits.
  • v3 logging: adopt ClientBuilder.Logger (slog) and drop internal/trace and logrus. Today the --debug trace transport wraps the retry transport (remote.go:411 vs :450), so retried attempts are invisible. Note that oras-go v3's ClientBuilder.buildTransport also places the logging transport outside retry.Transport while 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/cache with v3's public content/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, and internal/graph successors beyond content.Successors.
  • internal/contentutil/traverse.go TraversingTarget works around copyGraph skipping a sub-DAG when its root exists. Propose a CopyGraphOptions setting upstream.
  • Delete internal/mock, which has no importers.

Build & test

  • make test depends on tidy vendor (Makefile:55) and rewrites go.mod and vendor/ on every run. Drop those prerequisites and add a tidy-check target.
  • Replace the 13 copy-pasted build-* targets (Makefile:76-135) with one GOOS/GOARCH pattern rule.
  • Pin ginkgo in test/e2e/Dockerfile:49 (currently @latest) to the version in test/e2e/go.mod.
  • Add a fast local e2e path (docker run distribution + zot, ginkgo -p, prebuilt binary through ORAS_PATH) and keep Kubernetes for nightly runs.
  • Add unit tests for internal/registryutil (WithScopeHint), which has none.

Activity

  1. added
    enhancement
    on Oct 23, 2026
  2. self-assigned this
    on Oct 23, 2026
  3. added this to the future milestone on Oct 23, 2026
  4. TerryHowe commented on Oct 23, 2026

    @TerryHowe
    MemberAuthor

    The upstream logging-order bug noted under Errors, signals, logging is filed as oras-project/oras-go#1680.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions