MCPcopy Index your code
hub / github.com/coder/coder / readInvocationStdin

Function readInvocationStdin

cli/secret.go:247–261  ·  view source on GitHub ↗
(inv *serpent.Invocation)

Source from the content-addressed store, hash-verified

245}
246
247func readInvocationStdin(inv *serpent.Invocation) (string, bool, error) {
248 if isTTYIn(inv) {
249 return "", false, nil
250 }
251
252 bytes, err := io.ReadAll(inv.Stdin)
253 if err != nil {
254 return "", false, xerrors.Errorf("reading stdin: %w", err)
255 }
256 if len(bytes) == 0 {
257 return "", false, nil
258 }
259
260 return string(bytes), true, nil
261}
262
263// Shell helpers like echo usually append a line ending to piped stdin. We
264// treat a single trailing LF or CRLF as suspicious, but avoid flagging values

Callers 2

secretValueFunction · 0.85
TestReadInvocationStdinFunction · 0.85

Calls 3

isTTYInFunction · 0.85
ReadAllMethod · 0.45
ErrorfMethod · 0.45

Tested by 1

TestReadInvocationStdinFunction · 0.68