Skip to content

Commit 9b944da

Browse files
authored
Merge pull request #5589 from akshatsinha0/fix/check-prompt-write-error
fix: handle error when writing password prompt to stdout
2 parents 9f18062 + 5b37a6b commit 9b944da

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cmd/flux/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func main() {
180180

181181
// This is required because controller-runtime expects its consumers to
182182
// set a logger through log.SetLogger within 30 seconds of the program's
183-
// initalization. If not set, the entire debug stack is printed as an
183+
// initialization. If not set, the entire debug stack is printed as an
184184
// error, see: https://github.com/kubernetes-sigs/controller-runtime/blob/ed8be90/pkg/log/log.go#L59
185185
// Since we have our own logging and don't care about controller-runtime's
186186
// logger, we configure it's logger to do nothing.
@@ -225,7 +225,9 @@ func configureDefaultNamespace() {
225225
func readPasswordFromStdin(prompt string) (string, error) {
226226
var out string
227227
var err error
228-
fmt.Fprint(os.Stdout, prompt)
228+
if _, err := fmt.Fprint(os.Stdout, prompt); err != nil {
229+
return "", fmt.Errorf("failed to write prompt: %w", err)
230+
}
229231
stdinFD := int(os.Stdin.Fd())
230232
if term.IsTerminal(stdinFD) {
231233
var inBytes []byte

0 commit comments

Comments
 (0)