Skip to content

Commit 2cad149

Browse files
committed
Return ParseQualifier back. Will deprecate it in a separate PR
Signed-off-by: Ed Bartosh <[email protected]>
1 parent 54e62a8 commit 2cad149

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

pkg/cdi/qualified-device.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ func ParseDevice(device string) (string, string, string) {
6666
return parser.ParseDevice(device)
6767
}
6868

69+
// ParseQualifier splits a device qualifier into vendor and class.
70+
// The syntax for a device qualifier is
71+
//
72+
// "<vendor>/<class>"
73+
//
74+
// If parsing fails, an empty vendor and the class set to the
75+
// verbatim input is returned.
76+
//
77+
// Deprecated: use parser.ParseQualifier instead
78+
func ParseQualifier(kind string) (string, string) {
79+
return parser.ParseQualifier(kind)
80+
}
81+
6982
// ValidateVendorName checks the validity of a vendor name.
7083
// A vendor name may contain the following ASCII characters:
7184
// - upper- and lowercase letters ('A'-'Z', 'a'-'z')

pkg/cdi/spec.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ 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"
3231
cdi "tags.cncf.io/container-device-interface/specs-go"
3332
)
3433

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

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

111110
if spec.devices, err = spec.validate(); err != nil {
112111
return nil, fmt.Errorf("invalid CDI Spec: %w", err)
@@ -317,7 +316,7 @@ func GenerateTransientSpecName(vendor, class, transientID string) string {
317316
// the Spec does not contain a valid vendor or class, it returns
318317
// an empty name and a non-nil error.
319318
func GenerateNameForSpec(raw *cdi.Spec) (string, error) {
320-
vendor, class := parser.ParseQualifier(raw.Kind)
319+
vendor, class := ParseQualifier(raw.Kind)
321320
if vendor == "" {
322321
return "", fmt.Errorf("invalid vendor/class %q in Spec", raw.Kind)
323322
}
@@ -331,7 +330,7 @@ func GenerateNameForSpec(raw *cdi.Spec) (string, error) {
331330
// If the Spec does not contain a valid vendor or class, it returns an
332331
// an empty name and a non-nil error.
333332
func GenerateNameForTransientSpec(raw *cdi.Spec, transientID string) (string, error) {
334-
vendor, class := parser.ParseQualifier(raw.Kind)
333+
vendor, class := ParseQualifier(raw.Kind)
335334
if vendor == "" {
336335
return "", fmt.Errorf("invalid vendor/class %q in Spec", raw.Kind)
337336
}

0 commit comments

Comments
 (0)