@@ -29,8 +29,8 @@ import (
29
29
30
30
func cdiListVendors () {
31
31
var (
32
- registry = cdi .GetRegistry ()
33
- vendors = registry . SpecDB () .ListVendors ()
32
+ cache = cdi .GetDefaultCache ()
33
+ vendors = cache .ListVendors ()
34
34
)
35
35
36
36
if len (vendors ) == 0 {
@@ -41,20 +41,20 @@ func cdiListVendors() {
41
41
fmt .Printf ("CDI vendors found:\n " )
42
42
for idx , vendor := range vendors {
43
43
fmt .Printf (" %d. %q (%d CDI Spec Files)\n " , idx , vendor ,
44
- len (registry . SpecDB () .GetVendorSpecs (vendor )))
44
+ len (cache .GetVendorSpecs (vendor )))
45
45
}
46
46
}
47
47
48
48
func cdiListClasses () {
49
49
var (
50
- registry = cdi .GetRegistry ()
51
- vendors = map [string ][]string {}
50
+ cache = cdi .GetDefaultCache ()
51
+ vendors = map [string ][]string {}
52
52
)
53
53
54
- for _ , class := range registry . SpecDB () .ListClasses () {
54
+ for _ , class := range cache .ListClasses () {
55
55
vendors [class ] = []string {}
56
- for _ , vendor := range registry . SpecDB () .ListVendors () {
57
- for _ , spec := range registry . SpecDB () .GetVendorSpecs (vendor ) {
56
+ for _ , vendor := range cache .ListVendors () {
57
+ for _ , spec := range cache .GetVendorSpecs (vendor ) {
58
58
if spec .GetClass () == class {
59
59
vendors [class ] = append (vendors [class ], vendor )
60
60
}
@@ -68,7 +68,7 @@ func cdiListClasses() {
68
68
}
69
69
70
70
fmt .Printf ("CDI device classes found:\n " )
71
- for idx , class := range registry . SpecDB () .ListClasses () {
71
+ for idx , class := range cache .ListClasses () {
72
72
sort .Strings (vendors [class ])
73
73
fmt .Printf (" %d. %s (%d vendors: %s)\n " , idx , class ,
74
74
len (vendors [class ]), strings .Join (vendors [class ], ", " ))
@@ -77,8 +77,8 @@ func cdiListClasses() {
77
77
78
78
func cdiListDevices (verbose bool , format string ) {
79
79
var (
80
- registry = cdi .GetRegistry ()
81
- devices = registry . DeviceDB () .ListDevices ()
80
+ cache = cdi .GetDefaultCache ()
81
+ devices = cache .ListDevices ()
82
82
)
83
83
84
84
if len (devices ) == 0 {
@@ -88,7 +88,7 @@ func cdiListDevices(verbose bool, format string) {
88
88
89
89
fmt .Printf ("CDI devices found:\n " )
90
90
for idx , device := range devices {
91
- cdiPrintDevice (idx , registry . DeviceDB () .GetDevice (device ), verbose , format , 2 )
91
+ cdiPrintDevice (idx , cache .GetDevice (device ), verbose , format , 2 )
92
92
}
93
93
}
94
94
@@ -119,9 +119,9 @@ func cdiPrintDevice(idx int, dev *cdi.Device, verbose bool, format string, level
119
119
120
120
func cdiShowSpecDirs () {
121
121
var (
122
- registry = cdi .GetRegistry ()
123
- specDirs = registry .GetSpecDirectories ()
124
- cdiErrors = registry .GetErrors ()
122
+ cache = cdi .GetDefaultCache ()
123
+ specDirs = cache .GetSpecDirectories ()
124
+ cdiErrors = cache .GetErrors ()
125
125
)
126
126
fmt .Printf ("CDI Spec directories in use:\n " )
127
127
for prio , dir := range specDirs {
@@ -139,12 +139,12 @@ func cdiShowSpecDirs() {
139
139
140
140
func cdiInjectDevices (format string , ociSpec * oci.Spec , patterns []string ) error {
141
141
var (
142
- registry = cdi .GetRegistry ()
143
- matches = map [string ]struct {}{}
144
- devices = []string {}
142
+ cache = cdi .GetDefaultCache ()
143
+ matches = map [string ]struct {}{}
144
+ devices = []string {}
145
145
)
146
146
147
- for _ , device := range registry . DeviceDB () .ListDevices () {
147
+ for _ , device := range cache .ListDevices () {
148
148
for _ , glob := range patterns {
149
149
match , err := filepath .Match (glob , device )
150
150
if err != nil {
@@ -161,7 +161,7 @@ func cdiInjectDevices(format string, ociSpec *oci.Spec, patterns []string) error
161
161
}
162
162
sort .Strings (devices )
163
163
164
- unresolved , err := registry .InjectDevices (ociSpec , devices ... )
164
+ unresolved , err := cache .InjectDevices (ociSpec , devices ... )
165
165
166
166
if len (unresolved ) > 0 {
167
167
fmt .Printf ("Unresolved CDI devices:\n " )
@@ -242,18 +242,18 @@ func collectCDIDevicesFromOCISpec(spec *oci.Spec) []string {
242
242
243
243
func cdiListSpecs (verbose bool , format string , vendors ... string ) {
244
244
var (
245
- registry = cdi .GetRegistry ()
245
+ cache = cdi .GetDefaultCache ()
246
246
)
247
247
248
248
format = chooseFormat (format , "format-as.yaml" )
249
249
250
250
if len (vendors ) == 0 {
251
- vendors = registry . SpecDB () .ListVendors ()
251
+ vendors = cache .ListVendors ()
252
252
}
253
253
254
254
if len (vendors ) == 0 {
255
255
fmt .Printf ("No CDI Specs found.\n " )
256
- cdiErrors := registry .GetErrors ()
256
+ cdiErrors := cache .GetErrors ()
257
257
if len (cdiErrors ) > 0 {
258
258
for path , specErrors := range cdiErrors {
259
259
fmt .Printf ("%s has errors:\n " , path )
@@ -266,9 +266,9 @@ func cdiListSpecs(verbose bool, format string, vendors ...string) {
266
266
}
267
267
268
268
fmt .Printf ("CDI Specs found:\n " )
269
- for _ , vendor := range registry . SpecDB () .ListVendors () {
269
+ for _ , vendor := range cache .ListVendors () {
270
270
fmt .Printf ("Vendor %s:\n " , vendor )
271
- for _ , spec := range registry . SpecDB () .GetVendorSpecs (vendor ) {
271
+ for _ , spec := range cache .GetVendorSpecs (vendor ) {
272
272
cdiPrintSpec (spec , verbose , format , 2 )
273
273
cdiPrintSpecErrors (spec , verbose , 2 )
274
274
}
@@ -285,8 +285,8 @@ func cdiPrintSpec(spec *cdi.Spec, verbose bool, format string, level int) {
285
285
286
286
func cdiPrintSpecErrors (spec * cdi.Spec , verbose bool , level int ) {
287
287
var (
288
- registry = cdi .GetRegistry ()
289
- cdiErrors = registry .GetErrors ()
288
+ cache = cdi .GetDefaultCache ()
289
+ cdiErrors = cache .GetErrors ()
290
290
)
291
291
292
292
if len (cdiErrors ) > 0 {
@@ -302,7 +302,7 @@ func cdiPrintSpecErrors(spec *cdi.Spec, verbose bool, level int) {
302
302
}
303
303
}
304
304
305
- func cdiPrintRegistry (args ... string ) {
305
+ func cdiPrintCache (args ... string ) {
306
306
if len (args ) == 0 {
307
307
args = []string {"all" }
308
308
}
@@ -328,17 +328,17 @@ func cdiPrintRegistry(args ...string) {
328
328
}
329
329
}
330
330
331
- func cdiPrintRegistryErrors () {
331
+ func cdiPrintCacheErrors () {
332
332
var (
333
- registry = cdi .GetRegistry ()
334
- cdiErrors = registry .GetErrors ()
333
+ cache = cdi .GetDefaultCache ()
334
+ cdiErrors = cache .GetErrors ()
335
335
)
336
336
337
337
if len (cdiErrors ) == 0 {
338
338
return
339
339
}
340
340
341
- fmt .Printf ("CDI Registry has errors:\n " )
341
+ fmt .Printf ("CDI Cache has errors:\n " )
342
342
for path , specErrors := range cdiErrors {
343
343
fmt .Printf ("Spec file %s:\n " , path )
344
344
for idx , err := range specErrors {
0 commit comments