Skip to content

Commit 39d5eb5

Browse files
authored
Merge pull request #218 from bart0sh/PR019-remove-deprecated-APIs
Remove deprecated oci and qualified-device APIs
2 parents 46e163a + 78c9936 commit 39d5eb5

File tree

7 files changed

+11
-331
lines changed

7 files changed

+11
-331
lines changed

cmd/cdi/cmd/cdi-api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
oci "github.com/opencontainers/runtime-spec/specs-go"
2626
gen "github.com/opencontainers/runtime-tools/generate"
2727
"tags.cncf.io/container-device-interface/pkg/cdi"
28+
"tags.cncf.io/container-device-interface/pkg/parser"
2829
)
2930

3031
func cdiListVendors() {
@@ -230,7 +231,7 @@ func collectCDIDevicesFromOCISpec(spec *oci.Spec) []string {
230231
g.ClearLinuxDevices()
231232

232233
for _, d := range devices {
233-
if !cdi.IsQualifiedName(d.Path) {
234+
if !parser.IsQualifiedName(d.Path) {
234235
g.AddDevice(d)
235236
continue
236237
}

pkg/cdi/annotations.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func ParseAnnotations(annotations map[string]string) ([]string, []string, error)
7171
continue
7272
}
7373
for _, d := range strings.Split(value, ",") {
74-
if !IsQualifiedName(d) {
74+
if !parser.IsQualifiedName(d) {
7575
return nil, nil, fmt.Errorf("invalid CDI device name %q", d)
7676
}
7777
devices = append(devices, d)
@@ -130,7 +130,7 @@ func AnnotationKey(pluginName, deviceID string) (string, error) {
130130
func AnnotationValue(devices []string) (string, error) {
131131
value, sep := "", ""
132132
for _, d := range devices {
133-
if _, _, _, err := ParseQualifiedName(d); err != nil {
133+
if _, _, _, err := parser.ParseQualifiedName(d); err != nil {
134134
return "", err
135135
}
136136
value += sep + d

pkg/cdi/device.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (d *Device) edits() *ContainerEdits {
6767

6868
// Validate the device.
6969
func (d *Device) validate() error {
70-
if err := ValidateDeviceName(d.Name); err != nil {
70+
if err := parser.ValidateDeviceName(d.Name); err != nil {
7171
return err
7272
}
7373
name := d.Name

pkg/cdi/qualified-device.go

Lines changed: 0 additions & 113 deletions
This file was deleted.

pkg/cdi/qualified-device_test.go

Lines changed: 0 additions & 153 deletions
This file was deleted.

pkg/cdi/spec.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"sigs.k8s.io/yaml"
2929

3030
"tags.cncf.io/container-device-interface/internal/validation"
31+
"tags.cncf.io/container-device-interface/pkg/parser"
3132
cdi "tags.cncf.io/container-device-interface/specs-go"
3233
)
3334

@@ -105,7 +106,7 @@ func newSpec(raw *cdi.Spec, path string, priority int) (*Spec, error) {
105106
spec.path += defaultSpecExt
106107
}
107108

108-
spec.vendor, spec.class = ParseQualifier(spec.Kind)
109+
spec.vendor, spec.class = parser.ParseQualifier(spec.Kind)
109110

110111
if spec.devices, err = spec.validate(); err != nil {
111112
return nil, fmt.Errorf("invalid CDI Spec: %w", err)
@@ -211,10 +212,10 @@ func (s *Spec) validate() (map[string]*Device, error) {
211212
if err := cdi.ValidateVersion(s.Spec); err != nil {
212213
return nil, err
213214
}
214-
if err := ValidateVendorName(s.vendor); err != nil {
215+
if err := parser.ValidateVendorName(s.vendor); err != nil {
215216
return nil, err
216217
}
217-
if err := ValidateClassName(s.class); err != nil {
218+
if err := parser.ValidateClassName(s.class); err != nil {
218219
return nil, err
219220
}
220221
if err := validation.ValidateSpecAnnotations(s.Kind, s.Annotations); err != nil {
@@ -316,7 +317,7 @@ func GenerateTransientSpecName(vendor, class, transientID string) string {
316317
// the Spec does not contain a valid vendor or class, it returns
317318
// an empty name and a non-nil error.
318319
func GenerateNameForSpec(raw *cdi.Spec) (string, error) {
319-
vendor, class := ParseQualifier(raw.Kind)
320+
vendor, class := parser.ParseQualifier(raw.Kind)
320321
if vendor == "" {
321322
return "", fmt.Errorf("invalid vendor/class %q in Spec", raw.Kind)
322323
}
@@ -330,7 +331,7 @@ func GenerateNameForSpec(raw *cdi.Spec) (string, error) {
330331
// If the Spec does not contain a valid vendor or class, it returns an
331332
// an empty name and a non-nil error.
332333
func GenerateNameForTransientSpec(raw *cdi.Spec, transientID string) (string, error) {
333-
vendor, class := ParseQualifier(raw.Kind)
334+
vendor, class := parser.ParseQualifier(raw.Kind)
334335
if vendor == "" {
335336
return "", fmt.Errorf("invalid vendor/class %q in Spec", raw.Kind)
336337
}

0 commit comments

Comments
 (0)