@@ -52,11 +52,11 @@ func (m *Manager) ListDevices() []Device {
5252 kinds := make (map [string ]struct {})
5353 for _ , dev := range devs {
5454 kind , _ , _ := strings .Cut (dev , "=" )
55- spec := m .cache .GetDevice (dev ). GetSpec ( )
55+ dd := m .cache .GetDevice (dev )
5656 out = append (out , Device {
5757 Name : dev ,
5858 AutoAllow : true , // TODO
59- Annotations : spec . Annotations ,
59+ Annotations : deviceAnnotations ( dd ) ,
6060 })
6161 kinds [kind ] = struct {}{}
6262 }
@@ -154,8 +154,8 @@ func (m *Manager) parseDevice(dev *pb.CDIDevice) ([]string, error) {
154154 if ! strings .HasPrefix (d , kind + "=" ) {
155155 continue
156156 }
157- if dd := m .cache .GetDevice (d ). Device ; dd != nil {
158- if class , ok := dd . Annotations [deviceAnnotationClass ]; ok && class == name {
157+ if a := deviceAnnotations ( m .cache .GetDevice (d )); a != nil {
158+ if class , ok := a [deviceAnnotationClass ]; ok && class == name {
159159 out = append (out , d )
160160 }
161161 }
@@ -218,6 +218,22 @@ func (m *Manager) OnDemandInstaller(name string) (func(context.Context) error, b
218218 }, true
219219}
220220
221+ func deviceAnnotations (dev * cdi.Device ) map [string ]string {
222+ if dev == nil {
223+ return nil
224+ }
225+ out := make (map [string ]string )
226+ // spec annotations
227+ for k , v := range dev .GetSpec ().Annotations {
228+ out [k ] = v
229+ }
230+ // device annotations
231+ for k , v := range dev .Device .Annotations {
232+ out [k ] = v
233+ }
234+ return out
235+ }
236+
221237func dedupSlice (s []string ) []string {
222238 if len (s ) == 0 {
223239 return s
0 commit comments