chore: replace containerd/console with golang.org/x/term#2062
Open
TerryHowe wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2062 +/- ##
==========================================
+ Coverage 87.26% 87.30% +0.04%
==========================================
Files 138 138
Lines 5465 5467 +2
==========================================
+ Hits 4769 4773 +4
+ Misses 415 414 -1
+ Partials 281 280 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 <terrylhowe@gmail.com>
84354fa to
22e57e1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
github.com/containerd/console(notably a long-standing macOS bug) withgolang.org/x/term, maintained by the Go team and working on linux, mac and windows.consolepackage now renders to an internalterminalseam backed byx/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.containerd.NewPty); they useos.Pipeviatestutils.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 onterm.IsTerminal(os.Stderr)before any TTY handler is constructed). The previous containerd-basedNewConsolealso rejected non-terminal files as defense-in-depth; that check is now redundant, soNewConsolerejects only anilfile. The three*_invalidTTYhandler tests were updated to passnilaccordingly. 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)