in nri_device_injector/nri_device_injector.go [126:155]
func getDevices(ctrName string, podAnnotations map[string]string) ([]device, error) {
var (
deviceKey string = ctrDeviceKeyPrefix + ctrName
annotation []byte
parsedDevices []device
devices []device
)
if value, ok := podAnnotations[deviceKey]; ok {
annotation = []byte(value)
}
if annotation == nil {
return nil, nil
}
if err := yaml.Unmarshal(annotation, &parsedDevices); err != nil {
return nil, fmt.Errorf("invalid device annotation %q: %w", deviceKey, err)
}
paths := make(map[string]bool)
for _, d := range parsedDevices {
if _, got := paths[d.Path]; got {
continue
} else {
paths[d.Path] = true
devices = append(devices, d)
}
}
return devices, nil
}