Skip to content

Commit

Permalink
feat(cli): use scanner to read os.Stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
nilfr committed Oct 21, 2022
1 parent 3f0e41f commit 3a06c7a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/secrets/passphrase/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
package passphrase

import (
"bufio"
"context"
cryptorand "crypto/rand"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -225,11 +225,9 @@ func PromptForNewPassphrase(rotate bool) (string, secrets.Manager, error) {
firstMessage = "Enter your new passphrase to protect config/secrets"

if !isInteractive() {
text, err := io.ReadAll(os.Stdin)
if err != nil {
return "", nil, err
}
phrase = strings.TrimSpace(string(text))
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
phrase = strings.TrimSpace(scanner.Text())
break
}
}
Expand Down

0 comments on commit 3a06c7a

Please sign in to comment.