Skip to content

chore: replace containerd/console with golang.org/x/term - #2062

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
TerryHowe:feat/replace-containerd-console
Jul 11, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
TerryHowe:feat/replace-containerd-console

Conversation

@TerryHowe

Copy link
Copy Markdown
Member

Summary

  • Replaces the effectively-unmaintained github.com/containerd/console (notably a long-standing macOS bug) with golang.org/x/term, maintained by the Go team and working on linux, mac and windows.
  • The console package now renders to an internal terminal seam backed by x/term, keeping the terminal library isolated behind an interface so the backend can be swapped or extended later without touching callers. Cursor/escape-code logic is unchanged.
  • Test helpers no longer create a real pty (containerd.NewPty); they use os.Pipe via testutils.NewPipe/MatchPipe, so the previously linux-only TTY tests now run on all platforms (no creack/pty, no ConPTY, no x/sys).

Note for reviewers

Terminal detection already lives in option.Terminal.Parse (gating on term.IsTerminal(os.Stderr) before any TTY handler is constructed). The previous containerd-based NewConsole also rejected non-terminal files as defense-in-depth; that check is now redundant, so NewConsole rejects only a nil file. The three *_invalidTTY handler tests were updated to pass nil accordingly. Happy to thread an injectable console through the handler chain instead if you'd prefer to keep the non-terminal rejection.

Closes: #1449

Test plan

  • go build ./...
  • go vet ./...
  • go test ./... for affected packages, now passing on macOS (previously skipped)

@codecov

codecov Bot commented May 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.35%. Comparing base (835aade) to head (13f3daf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2062      +/-   ##
==========================================
+ Coverage   87.27%   87.35%   +0.07%     
==========================================
  Files         138      138              
  Lines        5486     5488       +2     
==========================================
+ Hits         4788     4794       +6     
+ Misses        417      414       -3     
+ Partials      281      280       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TerryHowe
TerryHowe force-pushed the feat/replace-containerd-console branch from 84354fa to 22e57e1 Compare June 10, 2026 14:07
@TerryHowe
TerryHowe requested a review from qweeah June 12, 2026 11:18
@TerryHowe

Copy link
Copy Markdown
Member Author

@renshao if you get a chance, maybe you could functionally test this on Windows

@renshao

renshao commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@renshao if you get a chance, maybe you could functionally test this on Windows

Yes, I can. I will report back my test result.

@renshao

renshao commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

I tested 3 scenarios (push, pull, cp) in Windows 11 PowerShell Terminal. I first compiled the binary oras.exe using:

go build -o oras.exe .\cmd\oras

oras push

image

oras pull

image

oras cp

image

The terminal UI looks fine, same as previous oras. The change looks good.

@TerryHowe

Copy link
Copy Markdown
Member Author

Thanks for testing @renshao

@TerryHowe
TerryHowe force-pushed the feat/replace-containerd-console branch from 22e57e1 to 958a74b Compare July 10, 2026 10:09
The github.com/containerd/console project is effectively unmaintained
(notably a long-standing macOS bug). Replace it with golang.org/x/term,
which is maintained by the Go team and works on linux, mac and windows.

The console package now renders to an internal terminal seam backed by
x/term, keeping the terminal library isolated behind an interface so the
backend can be swapped or extended without touching callers. Cursor and
escape-code logic is unchanged.

Test helpers no longer create a real pty (containerd.NewPty): they use
os.Pipe via testutils.NewPipe/MatchPipe, so the previously linux-only
tests now run on all platforms. Terminal detection remains centralized
in option.Terminal, so NewConsole only rejects a nil file.

Closes: oras-project#1449
Signed-off-by: Terry Howe <[email protected]>
@TerryHowe
TerryHowe force-pushed the feat/replace-containerd-console branch from 958a74b to 13f3daf Compare July 10, 2026 10:16

@shizhMSFT shizhMSFT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The change looks clean.

@TerryHowe
TerryHowe merged commit 00c0795 into oras-project:main Jul 11, 2026
9 checks passed
@TerryHowe
TerryHowe deleted the feat/replace-containerd-console branch July 11, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

containerd/console is broken for mac consider creack/pty

3 participants