| 53 | } |
| 54 | |
| 55 | func (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. |
| 73 | type bytesSource struct { |