MCPcopy Index your code
hub / github.com/smallstep/cli / ReadFile

Function ReadFile

utils/read.go:91–107  ·  view source on GitHub ↗

ReadFile returns the contents of the file identified by name. It reads from STDIN if name is a hyphen ("-").

(name string)

Source from the content-addressed store, hash-verified

89// ReadFile returns the contents of the file identified by name. It reads from
90// STDIN if name is a hyphen ("-").
91func ReadFile(name string) (b []byte, err error) {
92 if name == stdinFilename {
93 name = "/dev/stdin"
94 b, err = io.ReadAll(stdin)
95 } else {
96 var contents []byte
97 contents, err = os.ReadFile(name) // #nosec G703 -- file intended to be provided by user
98 if err != nil {
99 return nil, errs.FileError(err, name)
100 }
101 b, err = io.ReadAll(utfbom.SkipOnly(bytes.NewReader(contents)))
102 }
103 if err != nil {
104 return nil, errs.FileError(err, name)
105 }
106 return b, nil
107}

Callers 15

NewOfflineCAFunction · 0.92
signActionFunction · 0.92
inspectActionFunction · 0.92
publicActionFunction · 0.92
verifyActionFunction · 0.92
formatActionFunction · 0.92
fingerprintActionFunction · 0.92
inspectActionFunction · 0.92
inspectActionFunction · 0.92
needsRenewalActionFunction · 0.92
certificateActionFunction · 0.92
fingerprintFunction · 0.92

Calls 1

SkipOnlyFunction · 0.92

Tested by 2

TestReadFileFunction · 0.68
TestReadFileStdinFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…