@@ -52,11 +52,11 @@ func (m *Manager) ListDevices() []Device {
52
52
kinds := make (map [string ]struct {})
53
53
for _ , dev := range devs {
54
54
kind , _ , _ := strings .Cut (dev , "=" )
55
- spec := m .cache .GetDevice (dev ). GetSpec ( )
55
+ dd := m .cache .GetDevice (dev )
56
56
out = append (out , Device {
57
57
Name : dev ,
58
58
AutoAllow : true , // TODO
59
- Annotations : spec . Annotations ,
59
+ Annotations : deviceAnnotations ( dd ) ,
60
60
})
61
61
kinds [kind ] = struct {}{}
62
62
}
@@ -154,8 +154,8 @@ func (m *Manager) parseDevice(dev *pb.CDIDevice) ([]string, error) {
154
154
if ! strings .HasPrefix (d , kind + "=" ) {
155
155
continue
156
156
}
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 {
159
159
out = append (out , d )
160
160
}
161
161
}
@@ -218,6 +218,22 @@ func (m *Manager) OnDemandInstaller(name string) (func(context.Context) error, b
218
218
}, true
219
219
}
220
220
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
+
221
237
func dedupSlice (s []string ) []string {
222
238
if len (s ) == 0 {
223
239
return s
0 commit comments