in providers/linux/machineid.go [33:60]
func machineID(hostfs string) (string, error) {
var contents []byte
var err error
for _, file := range machineIDFiles {
contents, err = os.ReadFile(filepath.Join(hostfs, file))
if err != nil {
if os.IsNotExist(err) {
// Try next location
continue
}
// Return with error on any other error
return "", fmt.Errorf("failed to read %v: %w", file, err)
}
// Found it
break
}
if os.IsNotExist(err) {
// None of the locations existed
return "", types.ErrNotImplemented
}
contents = bytes.TrimSpace(contents)
return string(contents), nil
}