MCPcopy Index your code
hub / github.com/docker/docker-agent / Read

Method Read

pkg/config/sources.go:55–70  ·  view source on GitHub ↗
(context.Context)

Source from the content-addressed store, hash-verified

53}
54
55func (a fileSource) Read(context.Context) ([]byte, error) {
56 parentDir := a.ParentDir()
57 fs, err := os.OpenRoot(parentDir)
58 if err != nil {
59 return nil, fmt.Errorf("opening filesystem %s: %w", parentDir, err)
60 }
61 defer fs.Close()
62
63 fileName := filepath.Base(a.path)
64 data, err := fs.ReadFile(fileName)
65 if err != nil {
66 return nil, fmt.Errorf("reading config file %s: %w", fileName, err)
67 }
68
69 return data, nil
70}
71
72// bytesSource is used to load an agent configuration from a []byte.
73type bytesSource struct {

Callers

nothing calls this directly

Calls 3

ParentDirMethod · 0.95
ReadFileMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected