MCPcopy
hub / github.com/helm/helm / readFile

Function readFile

pkg/cli/values/options.go:119–138  ·  view source on GitHub ↗

readFile load a file from stdin, the local directory, or a remote file with a url.

(filePath string, p getter.Providers)

Source from the content-addressed store, hash-verified

117
118// readFile load a file from stdin, the local directory, or a remote file with a url.
119func readFile(filePath string, p getter.Providers) ([]byte, error) {
120 if strings.TrimSpace(filePath) == "-" {
121 return io.ReadAll(os.Stdin)
122 }
123 u, err := url.Parse(filePath)
124 if err != nil {
125 return nil, err
126 }
127
128 // FIXME: maybe someone handle other protocols like ftp.
129 g, err := p.ByScheme(u.Scheme)
130 if err != nil {
131 return os.ReadFile(filePath)
132 }
133 data, err := g.Get(filePath, getter.WithURL(filePath))
134 if err != nil {
135 return nil, err
136 }
137 return data.Bytes(), nil
138}

Callers 4

TestReadFileFunction · 0.85
TestReadFileOriginalFunction · 0.85
MergeValuesMethod · 0.85

Calls 3

WithURLFunction · 0.92
GetMethod · 0.65
BySchemeMethod · 0.45

Tested by 3

TestReadFileFunction · 0.68
TestReadFileOriginalFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…