Skip to content

cli/command: PromptUserForCredentials: don't mutate cli#7084

Open
thaJeztah wants to merge 1 commit into
docker:masterfrom
thaJeztah:prompt_cleans
Open

cli/command: PromptUserForCredentials: don't mutate cli#7084
thaJeztah wants to merge 1 commit into
docker:masterfrom
thaJeztah:prompt_cleans

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

PromptUserForCredentials accepted a Cli as argument so that it could swap the input stream on Windows (cli.SetIn).

Given that we only require this swap for the duration of this function (if needed at all), we can use a local variable that either uses cli.In() or os.Stdin (on Windows).

We currently still need to wrap the os.Stdin into a streams.In, but can use the raw os.Stdin (and/or cli.In().File()) once prompt.DisableInputEcho is updated.

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

PromptUserForCredentials accepted a Cli as argument so that it could swap
the input stream on Windows (cli.SetIn).

Given that we only require this swap for the duration of this function (if
needed at all), we can use a local variable that either uses cli.In() or
os.Stdin (on Windows).

We currently still need to wrap the os.Stdin into a streams.In, but can use
the raw os.Stdin (and/or cli.In().File()) once prompt.DisableInputEcho is
updated.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Jul 7, 2026
@thaJeztah thaJeztah added this to the 29.7.0 milestone Jul 7, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cli/command/registry.go 0.00% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@docker-agent docker-agent 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.

Assessment: 🟢 APPROVE

The refactor correctly narrows the PromptUserForCredentials parameter from the broad Cli interface to the narrower Streams interface, and replaces the mutation of cli.SetIn() with a local in variable scoped to the function. The Windows-specific stdin swap using streams.NewIn(os.Stdin) is logically sound, and no resource leaks or logic errors were identified in the changed lines.

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

Labels

kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants