Skip to content

Commit b7c7dba

Browse files
committed
remove Registry from the docs and comments
1 parent c6d1d5c commit b7c7dba

File tree

10 files changed

+76
-90
lines changed

10 files changed

+76
-90
lines changed

cmd/cdi/cmd/classes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import (
2020
"github.com/spf13/cobra"
2121
)
2222

23-
// classesCmd is our command for listing device classes in the registry.
23+
// classesCmd is our command for listing device classes in the cache.
2424
var classesCmd = &cobra.Command{
2525
Use: "classes",
2626
Short: "List CDI device classes",
27-
Long: `List CDI device classes found in the registry.`,
27+
Long: `List CDI device classes found in the cache.`,
2828
Run: func(cmd *cobra.Command, args []string) {
2929
cdiListClasses()
3030
},

cmd/cdi/cmd/devices.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ type devicesFlags struct {
2525
output string
2626
}
2727

28-
// devicesCmd is our command for listing devices found in the CDI registry.
28+
// devicesCmd is our command for listing devices found in the CDI cache.
2929
var devicesCmd = &cobra.Command{
3030
Aliases: []string{"devs", "dev"},
3131
Use: "devices",
32-
Short: "List devices in the CDI registry",
32+
Short: "List devices in the CDI cache",
3333
Long: `
34-
The 'devices' command lists devices found in the CDI registry.`,
34+
The 'devices' command lists devices found in the CDI cache.`,
3535
Run: func(cmd *cobra.Command, args []string) {
3636
cdiListDevices(devicesCfg.verbose, devicesCfg.output)
3737
},

cmd/cdi/cmd/dirs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var dirsCmd = &cobra.Command{
2525
Use: "dirs",
2626
Short: "Show CDI Spec directories in use",
2727
Long: `
28-
Show which directories are used by the registry to discover and
28+
Show which directories are used by the cache to discover and
2929
load CDI Specs. The later an entry is in the list the higher its
3030
priority. This priority is inherited by Spec files loaded from
3131
the directory and is used to resolve device conflicts. If there

cmd/cdi/cmd/monitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func monitorSpecDirs(args ...string) {
8181

8282
go func() {
8383
var (
84-
// don't print registry content more often than this
84+
// don't print cache content more often than this
8585
oneSecond = 1 * time.Second
8686
timer *time.Timer
8787
)

cmd/cdi/cmd/root.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ var (
3535
// rootCmd represents the base command when called without any subcommands
3636
var rootCmd = &cobra.Command{
3737
Use: "cdi",
38-
Short: "Inspect and interact with the CDI Registry",
38+
Short: "Inspect and interact with the CDI Cache",
3939
Long: `
4040
The 'cdi' utility allows you to inspect and interact with the
41-
CDI Registry. Various commands are available for listing CDI
41+
CDI Cache. Various commands are available for listing CDI
4242
Spec files, vendors, classes, devices, validating the content
43-
of the registry, injecting devices into OCI Specs, and for
44-
monitoring changes in the Registry.
43+
of the cache, injecting devices into OCI Specs, and for
44+
monitoring changes in the cache.
4545
4646
See cdi --help for a list of available commands. You can get
4747
additional help about <command> by using 'cdi <command> -h'.`,

cmd/cdi/cmd/specs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ var specsCmd = &cobra.Command{
3434
Use: "specs [vendor-list]",
3535
Short: "List available CDI Specs",
3636
Long: fmt.Sprintf(`
37-
The 'specs' command lists all CDI Specs present in the registry.
37+
The 'specs' command lists all CDI Specs present in the cache.
3838
If a vendor list is given, only CDI Specs by the given vendors are
39-
listed. The CDI Specs are discovered and loaded to the registry
40-
from CDI Spec directories. The default CDI Spec directories are:
39+
listed. The CDI Specs are discovered and loaded to the cache from
40+
CDI Spec directories. The default CDI Spec directories are:
4141
%s.`, strings.Join(cdi.DefaultSpecDirs, ", ")),
4242
Run: func(cmd *cobra.Command, vendors []string) {
4343
cdiListSpecs(specCfg.verbose, specCfg.output, vendors...)

cmd/cdi/cmd/validate.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ import (
2626
"tags.cncf.io/container-device-interface/pkg/cdi"
2727
)
2828

29-
// validateCmd is our CDI command for validating CDI Spec files in the registry.
29+
// validateCmd is our CDI command for validating CDI Spec files in the cache.
3030
var validateCmd = &cobra.Command{
3131
Use: "validate",
32-
Short: "List CDI registry errors",
32+
Short: "List CDI cache errors",
3333
Long: `
3434
The 'validate' command lists errors encountered during the population
35-
of the CDI registry. It exits with an exit status of 1 if any errors
36-
were reported by the registry.`,
35+
of the CDI cache. It exits with an exit status of 1 if any errors
36+
were reported by the cache.`,
3737
Run: func(cmd *cobra.Command, args []string) {
3838
cache := cdi.GetDefaultCache()
3939
cdiErrors := cache.GetErrors()

cmd/cdi/cmd/vendors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
var vendorsCmd = &cobra.Command{
2525
Use: "vendors",
2626
Short: "List vendors",
27-
Long: `List vendors with CDI Specs in the registry.`,
27+
Long: `List vendors with CDI Specs in the cache.`,
2828
Run: func(cmd *cobra.Command, args []string) {
2929
cdiListVendors()
3030
},

pkg/cdi/doc.go

Lines changed: 56 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -35,48 +35,35 @@
3535
// available and instantiated the first time it is referenced directly
3636
// or indirectly. The most frequently used cache functions are available
3737
// as identically named package level functions which operate on the
38-
// default cache instance. Moreover, the registry also operates on the
39-
// same default cache. We plan to deprecate the registry and eventually
40-
// remove it in a future release.
41-
//
42-
// # CDI Registry
43-
//
44-
// Note: the Registry and its related interfaces are deprecated and will
45-
// be removed in a future version. Please use the default cache and its
46-
// related package-level function instead.
47-
//
48-
// The primary interface to interact with CDI devices is the Registry. It
49-
// is essentially a cache of all Specs and devices discovered in standard
50-
// CDI directories on the host. The registry has two main functionality,
51-
// injecting devices into an OCI Spec and refreshing the cache of CDI
52-
// Specs and devices.
38+
// default cache instance.
5339
//
5440
// # Device Injection
5541
//
56-
// Using the Registry one can inject CDI devices into a container with code
42+
// Using the Cache one can inject CDI devices into a container with code
5743
// similar to the following snippet:
5844
//
59-
// import (
60-
// "fmt"
61-
// "strings"
45+
// import (
46+
// "fmt"
47+
// "strings"
6248
//
63-
// log "github.com/sirupsen/logrus"
49+
// log "github.com/sirupsen/logrus"
6450
//
65-
// "tags.cncf.io/container-device-interface/pkg/cdi"
66-
// oci "github.com/opencontainers/runtime-spec/specs-go"
67-
// )
51+
// "tags.cncf.io/container-device-interface/pkg/cdi"
52+
// oci "github.com/opencontainers/runtime-spec/specs-go"
53+
// )
6854
//
69-
// func injectCDIDevices(spec *oci.Spec, devices []string) error {
70-
// log.Debug("pristine OCI Spec: %s", dumpSpec(spec))
55+
// func injectCDIDevices(spec *oci.Spec, devices []string) error {
56+
// log.Debug("pristine OCI Spec: %s", dumpSpec(spec))
7157
//
72-
// unresolved, err := cdi.GetRegistry().InjectDevices(spec, devices)
73-
// if err != nil {
74-
// return fmt.Errorf("CDI device injection failed: %w", err)
75-
// }
58+
// cache := cdi.GetDefaultCache()
59+
// unresolved, err := cache.InjectDevices(spec, devices)
60+
// if err != nil {
61+
// return fmt.Errorf("CDI device injection failed: %w", err)
62+
// }
7663
//
77-
// log.Debug("CDI-updated OCI Spec: %s", dumpSpec(spec))
78-
// return nil
79-
// }
64+
// log.Debug("CDI-updated OCI Spec: %s", dumpSpec(spec))
65+
// return nil
66+
// }
8067
//
8168
// # Cache Refresh
8269
//
@@ -99,40 +86,40 @@
9986
// CDI Spec cache is up to date before performing device injection.
10087
// A code snippet similar to the following accmplishes that:
10188
//
102-
// import (
103-
// "fmt"
104-
// "strings"
89+
// import (
90+
// "fmt"
91+
// "strings"
10592
//
106-
// log "github.com/sirupsen/logrus"
93+
// log "github.com/sirupsen/logrus"
10794
//
108-
// "tags.cncf.io/container-device-interface/pkg/cdi"
109-
// oci "github.com/opencontainers/runtime-spec/specs-go"
110-
// )
95+
// "tags.cncf.io/container-device-interface/pkg/cdi"
96+
// specs "github.com/opencontainers/runtime-spec/specs-go"
97+
// )
11198
//
112-
// func injectCDIDevices(spec *oci.Spec, devices []string) error {
113-
// registry := cdi.GetRegistry()
99+
// func injectCDIDevices(spec *specs.Spec, devices []string) error {
100+
// cache := cdi.GetDefaultCache()
114101
//
115-
// if err := registry.Refresh(); err != nil {
116-
// // Note:
117-
// // It is up to the implementation to decide whether
118-
// // to abort injection on errors. A failed Refresh()
119-
// // does not necessarily render the registry unusable.
120-
// // For instance, a parse error in a Spec file for
121-
// // vendor A does not have any effect on devices of
122-
// // vendor B...
123-
// log.Warnf("pre-injection Refresh() failed: %v", err)
124-
// }
102+
// if err := cache.Refresh(); err != nil {
103+
// // Note:
104+
// // It is up to the implementation to decide whether
105+
// // to abort injection on errors. A failed Refresh()
106+
// // does not necessarily render the cache unusable.
107+
// // For instance, a parse error in a Spec file for
108+
// // vendor A does not have any effect on devices of
109+
// // vendor B...
110+
// log.Warnf("pre-injection Refresh() failed: %v", err)
111+
// }
125112
//
126-
// log.Debug("pristine OCI Spec: %s", dumpSpec(spec))
113+
// log.Debug("pristine OCI Spec: %s", dumpSpec(spec))
127114
//
128-
// unresolved, err := registry.InjectDevices(spec, devices)
129-
// if err != nil {
130-
// return fmt.Errorf("CDI device injection failed: %w", err)
131-
// }
115+
// unresolved, err := cache.InjectDevices(spec, devices)
116+
// if err != nil {
117+
// return fmt.Errorf("CDI device injection failed: %w", err)
118+
// }
132119
//
133-
// log.Debug("CDI-updated OCI Spec: %s", dumpSpec(spec))
134-
// return nil
135-
// }
120+
// log.Debug("CDI-updated OCI Spec: %s", dumpSpec(spec))
121+
// return nil
122+
// }
136123
//
137124
// # Generated Spec Files, Multiple Directories, Device Precedence
138125
//
@@ -186,13 +173,13 @@
186173
//
187174
// "fmt"
188175
// ...
189-
// "tags.cncf.io/container-device-interface/specs-go"
176+
// specs "tags.cncf.io/container-device-interface/specs-go"
190177
// "tags.cncf.io/container-device-interface/pkg/cdi"
191178
//
192179
// )
193180
//
194181
// func generateDeviceSpecs() error {
195-
// registry := cdi.GetRegistry()
182+
// cache := specs.GetDefaultCache()
196183
// spec := &specs.Spec{
197184
// Version: specs.CurrentVersion,
198185
// Kind: vendor+"/"+class,
@@ -210,7 +197,7 @@
210197
// return fmt.Errorf("failed to generate Spec name: %w", err)
211198
// }
212199
//
213-
// return registry.SpecDB().WriteSpec(spec, specName)
200+
// return cache.WriteSpec(spec, specName)
214201
// }
215202
//
216203
// Similarly, generating and later cleaning up transient Spec files can be
@@ -222,14 +209,14 @@
222209
// import (
223210
//
224211
// "fmt"
225-
// ...
226-
// "tags.cncf.io/container-device-interface/specs-go"
212+
//
213+
// specs "tags.cncf.io/container-device-interface/specs-go"
227214
// "tags.cncf.io/container-device-interface/pkg/cdi"
228215
//
229216
// )
230217
//
231218
// func generateTransientSpec(ctr Container) error {
232-
// registry := cdi.GetRegistry()
219+
// cache := specs.GetDefaultCache()
233220
// devices := getContainerDevs(ctr, vendor, class)
234221
// spec := &specs.Spec{
235222
// Version: specs.CurrentVersion,
@@ -257,21 +244,21 @@
257244
// return fmt.Errorf("failed to generate Spec name: %w", err)
258245
// }
259246
//
260-
// return registry.SpecDB().WriteSpec(spec, specName)
247+
// return cache.WriteSpec(spec, specName)
261248
// }
262249
//
263250
// func removeTransientSpec(ctr Container) error {
264-
// registry := cdi.GetRegistry()
251+
// cache := specs.GetDefaultCache()
265252
// transientID := getSomeSufficientlyUniqueIDForContainer(ctr)
266253
// specName := cdi.GenerateNameForTransientSpec(vendor, class, transientID)
267254
//
268-
// return registry.SpecDB().RemoveSpec(specName)
255+
// return cache.RemoveSpec(specName)
269256
// }
270257
//
271258
// # CDI Spec Validation
272259
//
273260
// This package performs both syntactic and semantic validation of CDI
274-
// Spec file data when a Spec file is loaded via the registry or using
261+
// Spec file data when a Spec file is loaded via the cache or using
275262
// the ReadSpec API function. As part of the semantic verification, the
276263
// Spec file is verified against the CDI Spec JSON validation schema.
277264
//

pkg/cdi/spec-dirs.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ var (
3535
// While altering this variable changes the package defaults,
3636
// the preferred way of overriding the default directories is
3737
// to use a WithSpecDirs options. Otherwise the change is only
38-
// effective if it takes place before creating the Registry or
39-
// other Cache instances.
38+
// effective if it takes place before creating the cache instance.
4039
DefaultSpecDirs = []string{DefaultStaticDir, DefaultDynamicDir}
4140
// ErrStopScan can be returned from a ScanSpecFunc to stop the scan.
4241
ErrStopScan = errors.New("stop Spec scan")

0 commit comments

Comments
 (0)