Skip to content

Remove deprecated oci and qualified-device APIs #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/cdi/cmd/cdi-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
oci "github.com/opencontainers/runtime-spec/specs-go"
gen "github.com/opencontainers/runtime-tools/generate"
"tags.cncf.io/container-device-interface/pkg/cdi"
"tags.cncf.io/container-device-interface/pkg/parser"
)

func cdiListVendors() {
Expand Down Expand Up @@ -230,7 +231,7 @@ func collectCDIDevicesFromOCISpec(spec *oci.Spec) []string {
g.ClearLinuxDevices()

for _, d := range devices {
if !cdi.IsQualifiedName(d.Path) {
if !parser.IsQualifiedName(d.Path) {
g.AddDevice(d)
continue
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cdi/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func ParseAnnotations(annotations map[string]string) ([]string, []string, error)
continue
}
for _, d := range strings.Split(value, ",") {
if !IsQualifiedName(d) {
if !parser.IsQualifiedName(d) {
return nil, nil, fmt.Errorf("invalid CDI device name %q", d)
}
devices = append(devices, d)
Expand Down Expand Up @@ -130,7 +130,7 @@ func AnnotationKey(pluginName, deviceID string) (string, error) {
func AnnotationValue(devices []string) (string, error) {
value, sep := "", ""
for _, d := range devices {
if _, _, _, err := ParseQualifiedName(d); err != nil {
if _, _, _, err := parser.ParseQualifiedName(d); err != nil {
return "", err
}
value += sep + d
Expand Down
2 changes: 1 addition & 1 deletion pkg/cdi/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (d *Device) edits() *ContainerEdits {

// Validate the device.
func (d *Device) validate() error {
if err := ValidateDeviceName(d.Name); err != nil {
if err := parser.ValidateDeviceName(d.Name); err != nil {
return err
}
name := d.Name
Expand Down
113 changes: 0 additions & 113 deletions pkg/cdi/qualified-device.go

This file was deleted.

153 changes: 0 additions & 153 deletions pkg/cdi/qualified-device_test.go

This file was deleted.

11 changes: 6 additions & 5 deletions pkg/cdi/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"sigs.k8s.io/yaml"

"tags.cncf.io/container-device-interface/internal/validation"
"tags.cncf.io/container-device-interface/pkg/parser"
cdi "tags.cncf.io/container-device-interface/specs-go"
)

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

spec.vendor, spec.class = ParseQualifier(spec.Kind)
spec.vendor, spec.class = parser.ParseQualifier(spec.Kind)

if spec.devices, err = spec.validate(); err != nil {
return nil, fmt.Errorf("invalid CDI Spec: %w", err)
Expand Down Expand Up @@ -211,10 +212,10 @@ func (s *Spec) validate() (map[string]*Device, error) {
if err := cdi.ValidateVersion(s.Spec); err != nil {
return nil, err
}
if err := ValidateVendorName(s.vendor); err != nil {
if err := parser.ValidateVendorName(s.vendor); err != nil {
return nil, err
}
if err := ValidateClassName(s.class); err != nil {
if err := parser.ValidateClassName(s.class); err != nil {
return nil, err
}
if err := validation.ValidateSpecAnnotations(s.Kind, s.Annotations); err != nil {
Expand Down Expand Up @@ -316,7 +317,7 @@ func GenerateTransientSpecName(vendor, class, transientID string) string {
// the Spec does not contain a valid vendor or class, it returns
// an empty name and a non-nil error.
func GenerateNameForSpec(raw *cdi.Spec) (string, error) {
vendor, class := ParseQualifier(raw.Kind)
vendor, class := parser.ParseQualifier(raw.Kind)
if vendor == "" {
return "", fmt.Errorf("invalid vendor/class %q in Spec", raw.Kind)
}
Expand All @@ -330,7 +331,7 @@ func GenerateNameForSpec(raw *cdi.Spec) (string, error) {
// If the Spec does not contain a valid vendor or class, it returns an
// an empty name and a non-nil error.
func GenerateNameForTransientSpec(raw *cdi.Spec, transientID string) (string, error) {
vendor, class := ParseQualifier(raw.Kind)
vendor, class := parser.ParseQualifier(raw.Kind)
if vendor == "" {
return "", fmt.Errorf("invalid vendor/class %q in Spec", raw.Kind)
}
Expand Down
Loading